service: add count per lcore
authorPavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Tue, 29 Aug 2017 12:32:51 +0000 (18:02 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 14 Sep 2017 16:16:07 +0000 (18:16 +0200)
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>
lib/librte_eal/bsdapp/eal/rte_eal_version.map
lib/librte_eal/common/include/rte_service.h
lib/librte_eal/common/rte_service.c
lib/librte_eal/linuxapp/eal/rte_eal_version.map

index aac6fd7..79e7d31 100644 (file)
@@ -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;
index 7c6f738..5ea81c4 100644 (file)
@@ -370,6 +370,19 @@ int32_t rte_service_set_stats_enable(struct rte_service_spec *service,
  */
 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
index 7efb76d..616bad3 100644 (file)
@@ -396,6 +396,19 @@ rte_service_lcore_list(uint32_t array[], uint32_t n)
        return count;
 }
 
+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)
 {
index 3a8f154..468c706 100644 (file)
@@ -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;