[dpdk-dev,v3,5/7] service cores: enable event/sw with service

Message ID 1499031314-7172-6-git-send-email-harry.van.haaren@intel.com (mailing list archive)
State Changes Requested, archived
Delegated to: Thomas Monjalon
Headers

Checks

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

Commit Message

Van Haaren, Harry July 2, 2017, 9:35 p.m. UTC
  This commit shows how easy it is to enable a specific
DPDK component with a service callback, in order to get
CPU cycles for it.

The beauty of this method is that the service is unaware
of how much CPU time it is getting - the application can
decide how to split and slice cores and map them to the
registered services.

Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

---

v2:
- Remove #include <rte_cycles.h> (Jerin)
- Remove development prints (Jerin)
- Track service name in PMD
- Print warning if service does not have an lcore mapped (Jerin)
---
 drivers/event/sw/sw_evdev.c | 32 ++++++++++++++++++++++++++++++++
 drivers/event/sw/sw_evdev.h |  3 +++
 2 files changed, 35 insertions(+)
  

Comments

Jerin Jacob July 4, 2017, 10:52 a.m. UTC | #1
-----Original Message-----
> Date: Sun, 2 Jul 2017 22:35:12 +0100
> From: Harry van Haaren <harry.van.haaren@intel.com>
> To: dev@dpdk.org
> CC: jerin.jacob@caviumnetworks.com, thomas@monjalon.net,
>  keith.wiles@intel.com, bruce.richardson@intel.com, Harry van Haaren
>  <harry.van.haaren@intel.com>
> Subject: [PATCH v3 5/7] service cores: enable event/sw with service
> X-Mailer: git-send-email 2.7.4
> 
> This commit shows how easy it is to enable a specific
> DPDK component with a service callback, in order to get
> CPU cycles for it.
> 
> The beauty of this method is that the service is unaware
> of how much CPU time it is getting - the application can
> decide how to split and slice cores and map them to the
> registered services.
> 
> Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
> 
> ---
> 
> v2:
> - Remove #include <rte_cycles.h> (Jerin)
> - Remove development prints (Jerin)
> - Track service name in PMD
> - Print warning if service does not have an lcore mapped (Jerin)
> ---
>  drivers/event/sw/sw_evdev.c | 32 ++++++++++++++++++++++++++++++++
>  drivers/event/sw/sw_evdev.h |  3 +++
>  2 files changed, 35 insertions(+)
> 
> diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
> index fe2a61e..baab376 100644
> --- a/drivers/event/sw/sw_evdev.c
> +++ b/drivers/event/sw/sw_evdev.c
> @@ -38,6 +38,7 @@
>  #include <rte_kvargs.h>
>  #include <rte_ring.h>
>  #include <rte_errno.h>
> +#include <rte_service_private.h>
>  
>  #include "sw_evdev.h"
>  #include "iq_ring.h"
> @@ -597,6 +598,13 @@ sw_start(struct rte_eventdev *dev)
>  {
>  	unsigned int i, j;
>  	struct sw_evdev *sw = sw_pmd_priv(dev);
> +
> +	/* check a service core is mapped to this service */
> +	struct rte_service_spec *s = rte_service_get_by_name(sw->service_name);
> +	if (!rte_service_is_running(s))
> +		SW_LOG_ERR("Warning: No Service core enabled on service %s\n",
> +				s->name);

For now, we can print just Warning. Once we remove schedule api from
eventdev then we can make it as error. Right?

Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
  
Van Haaren, Harry July 7, 2017, 4:28 p.m. UTC | #2
> From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]
> Sent: Tuesday, July 4, 2017 11:53 AM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>
> Cc: dev@dpdk.org; thomas@monjalon.net; Wiles, Keith <keith.wiles@intel.com>; Richardson,
> Bruce <bruce.richardson@intel.com>
> Subject: Re: [PATCH v3 5/7] service cores: enable event/sw with service
> 
> -----Original Message-----
> > Date: Sun, 2 Jul 2017 22:35:12 +0100
> > From: Harry van Haaren <harry.van.haaren@intel.com>
> > To: dev@dpdk.org
> > CC: jerin.jacob@caviumnetworks.com, thomas@monjalon.net,
> >  keith.wiles@intel.com, bruce.richardson@intel.com, Harry van Haaren
> >  <harry.van.haaren@intel.com>
> > Subject: [PATCH v3 5/7] service cores: enable event/sw with service
> > X-Mailer: git-send-email 2.7.4
> >
> > This commit shows how easy it is to enable a specific
> > DPDK component with a service callback, in order to get
> > CPU cycles for it.
> >
> > The beauty of this method is that the service is unaware
> > of how much CPU time it is getting - the application can
> > decide how to split and slice cores and map them to the
> > registered services.
> >
> > Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>

<snip>

> > +
> > +	/* check a service core is mapped to this service */
> > +	struct rte_service_spec *s = rte_service_get_by_name(sw->service_name);
> > +	if (!rte_service_is_running(s))
> > +		SW_LOG_ERR("Warning: No Service core enabled on service %s\n",
> > +				s->name);
> 
> For now, we can print just Warning. Once we remove schedule api from
> eventdev then we can make it as error. Right?

Yes correct.

> Acked-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

Thanks, will include in v+1.
  

Patch

diff --git a/drivers/event/sw/sw_evdev.c b/drivers/event/sw/sw_evdev.c
index fe2a61e..baab376 100644
--- a/drivers/event/sw/sw_evdev.c
+++ b/drivers/event/sw/sw_evdev.c
@@ -38,6 +38,7 @@ 
 #include <rte_kvargs.h>
 #include <rte_ring.h>
 #include <rte_errno.h>
+#include <rte_service_private.h>
 
 #include "sw_evdev.h"
 #include "iq_ring.h"
@@ -597,6 +598,13 @@  sw_start(struct rte_eventdev *dev)
 {
 	unsigned int i, j;
 	struct sw_evdev *sw = sw_pmd_priv(dev);
+
+	/* check a service core is mapped to this service */
+	struct rte_service_spec *s = rte_service_get_by_name(sw->service_name);
+	if (!rte_service_is_running(s))
+		SW_LOG_ERR("Warning: No Service core enabled on service %s\n",
+				s->name);
+
 	/* check all ports are set up */
 	for (i = 0; i < sw->port_count; i++)
 		if (sw->ports[i].rx_worker_ring == NULL) {
@@ -699,6 +707,14 @@  set_credit_quanta(const char *key __rte_unused, const char *value, void *opaque)
 	return 0;
 }
 
+
+static int32_t sw_sched_service_func(void *args)
+{
+	struct rte_eventdev *dev = args;
+	sw_event_schedule(dev);
+	return 0;
+}
+
 static int
 sw_probe(struct rte_vdev_device *vdev)
 {
@@ -810,6 +826,22 @@  sw_probe(struct rte_vdev_device *vdev)
 	sw->credit_update_quanta = credit_quanta;
 	sw->sched_quanta = sched_quanta;
 
+	/* register service with EAL */
+	struct rte_service_spec service;
+	memset(&service, 0, sizeof(struct rte_service_spec));
+	snprintf(service.name, sizeof(service.name), "%s_service", name);
+	snprintf(sw->service_name, sizeof(sw->service_name), "%s_service",
+			name);
+	service.socket_id = socket_id;
+	service.callback = sw_sched_service_func;
+	service.callback_userdata = (void *)dev;
+
+	int32_t ret = rte_service_register(&service);
+	if (ret) {
+		SW_LOG_ERR("service register() failed");
+		return -ENOEXEC;
+	}
+
 	return 0;
 }
 
diff --git a/drivers/event/sw/sw_evdev.h b/drivers/event/sw/sw_evdev.h
index 0d7f94f..3e83823 100644
--- a/drivers/event/sw/sw_evdev.h
+++ b/drivers/event/sw/sw_evdev.h
@@ -59,6 +59,7 @@ 
 
 #define EVENTDEV_NAME_SW_PMD event_sw
 #define SW_PMD_NAME RTE_STR(event_sw)
+#define SW_PMD_NAME_MAX 64
 
 #define SW_SCHED_TYPE_DIRECT (RTE_SCHED_TYPE_PARALLEL + 1)
 
@@ -276,6 +277,8 @@  struct sw_evdev {
 	/* store num stats and offset of the stats for each queue */
 	uint16_t xstats_count_per_qid[RTE_EVENT_MAX_QUEUES_PER_DEV];
 	uint16_t xstats_offset_for_qid[RTE_EVENT_MAX_QUEUES_PER_DEV];
+
+	char service_name[SW_PMD_NAME_MAX];
 };
 
 static inline struct sw_evdev *