[dpdk-dev,v4] service: add API for service count per lcore

Message ID 1504009971-11282-1-git-send-email-pbhagavatula@caviumnetworks.com (mailing list archive)
State Accepted, archived
Headers

Checks

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

Commit Message

Pavan Nikhilesh Aug. 29, 2017, 12:32 p.m. UTC
  This new API returns the number of services that are running on a specific
service core. It allows an application to decide which service core to run
a new service on.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
v4 changes:
  - fix doxygen errors

v3 changes:
  - fix compilation issues with .map files

v2 changes:
  - reword the commit title according to the check-git-log.sh
  - modify return types
  - add function to .map file

 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_service.h     | 13 +++++++++++++
 lib/librte_eal/common/rte_service.c             | 13 +++++++++++++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 4 files changed, 28 insertions(+)

--
2.7.4
  

Comments

Van Haaren, Harry Aug. 29, 2017, 1:14 p.m. UTC | #1
> From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com]
> Sent: Tuesday, August 29, 2017 1:33 PM
> To: Van Haaren, Harry <harry.van.haaren@intel.com>
> Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> Subject: [dpdk-dev] [PATCH v4] service: add API for service count per lcore
> 
> This new API returns the number of services that are running on a specific
> service core. It allows an application to decide which service core to run
> a new service on.
> 
> Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>

Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
  
Thomas Monjalon Sept. 14, 2017, 4:17 p.m. UTC | #2
29/08/2017 15:14, Van Haaren, Harry:
> > From: Pavan Nikhilesh [mailto:pbhagavatula@caviumnetworks.com]
> > Sent: Tuesday, August 29, 2017 1:33 PM
> > To: Van Haaren, Harry <harry.van.haaren@intel.com>
> > Cc: dev@dpdk.org; Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> > Subject: [dpdk-dev] [PATCH v4] service: add API for service count per lcore
> > 
> > This new API returns the number of services that are running on a specific
> > service core. It allows an application to decide which service core to run
> > a new service on.
> > 
> > Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
> 
> Acked-by: Harry van Haaren <harry.van.haaren@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index aac6fd7..79e7d31 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -222,6 +222,7 @@  EXPERIMENTAL {
 	rte_service_is_running;
 	rte_service_lcore_add;
 	rte_service_lcore_count;
+	rte_service_lcore_count_services;
 	rte_service_lcore_del;
 	rte_service_lcore_list;
 	rte_service_lcore_reset_all;
diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h
index 7c6f738..5ea81c4 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -374,6 +374,19 @@  int32_t rte_service_lcore_list(uint32_t array[], uint32_t n);
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice
  *
+ * Get the numer of services running on the supplied lcore.
+ *
+ * @param lcore Id of the service core.
+ * @retval >=0 Number of services registered to this core.
+ * @retval -EINVAL Invalid lcore provided
+ * @retval -ENOTSUP The provided lcore is not a service core.
+ */
+int32_t rte_service_lcore_count_services(uint32_t lcore);
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
  * Dumps any information available about the service. If service is NULL,
  * dumps info for all services.
  */
diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index 7efb76d..616bad3 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -397,6 +397,19 @@  rte_service_lcore_list(uint32_t array[], uint32_t n)
 }

 int32_t
+rte_service_lcore_count_services(uint32_t lcore)
+{
+	if (lcore >= RTE_MAX_LCORE)
+		return -EINVAL;
+
+	struct core_state *cs = &lcore_states[lcore];
+	if (!cs->is_service_core)
+		return -ENOTSUP;
+
+	return __builtin_popcountll(cs->service_mask);
+}
+
+int32_t
 rte_service_start_with_defaults(void)
 {
 	/* create a default mapping from cores to services, then start the
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 3a8f154..468c706 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -227,6 +227,7 @@  EXPERIMENTAL {
 	rte_service_is_running;
 	rte_service_lcore_add;
 	rte_service_lcore_count;
+	rte_service_lcore_count_services;
 	rte_service_lcore_del;
 	rte_service_lcore_list;
 	rte_service_lcore_reset_all;