* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
- * Enable a core to run a service.
+ * Map or unmap a lcore to a service.
*
- * Each core can be added or removed from running specific services. This
- * functions adds *lcore* to the set of cores that will run *service*.
+ * Each core can be added or removed from running a specific service. This
+ * function enables or disables *lcore* to run *service_id*.
*
* If multiple cores are enabled on a service, an atomic is used to ensure that
* only one cores runs the service at a time. The exception to this is when
* called RTE_SERVICE_CAP_MT_SAFE. With the multi-thread safe capability set,
* the service function can be run on multiple threads at the same time.
*
- * @retval 0 lcore added successfully
- * @retval -EINVAL An invalid service or lcore was provided.
- */
-int32_t rte_service_enable_on_lcore(struct rte_service_spec *service,
- uint32_t lcore);
-
-/**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice
- *
- * Disable a core to run a service.
+ * @param service_id the service to apply the lcore to
+ * @param lcore The lcore that will be mapped to service
+ * @param enable Zero to unmap or disable the core, non-zero to enable
*
- * Each core can be added or removed from running specific services. This
- * functions removes *lcore* to the set of cores that will run *service*.
- *
- * @retval 0 Lcore removed successfully
+ * @retval 0 lcore map updated successfully
* @retval -EINVAL An invalid service or lcore was provided.
*/
-int32_t rte_service_disable_on_lcore(struct rte_service_spec *service,
- uint32_t lcore);
+int32_t rte_service_map_lcore_set(uint32_t service_id, uint32_t lcore,
+ uint32_t enable);
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
- * Return if an lcore is enabled for the service.
+ * Retrieve the mapping of an lcore to a service.
*
- * This function allows the application to query if *lcore* is currently set to
- * run *service*.
+ * @param service_id the service to apply the lcore to
+ * @param lcore The lcore that will be mapped to service
*
- * @retval 1 Lcore enabled on this lcore
- * @retval 0 Lcore disabled on this lcore
+ * @retval 1 lcore is mapped to service
+ * @retval 0 lcore is not mapped to service
* @retval -EINVAL An invalid service or lcore was provided.
*/
-int32_t rte_service_get_enabled_on_lcore(struct rte_service_spec *service,
- uint32_t lcore);
-
+int32_t rte_service_map_lcore_get(uint32_t service_id, uint32_t lcore);
/**
* @warning
* should multiplex to a single core, or 1:1 if there are the
* same amount of services as service-cores
*/
- ret = rte_service_enable_on_lcore(s, ids[lcore_iter]);
+ ret = rte_service_map_lcore_set(i, ids[lcore_iter], 1);
if (ret)
return -ENODEV;
return 0;
}
-int32_t rte_service_get_enabled_on_lcore(struct rte_service_spec *service,
- uint32_t lcore)
-{
- uint32_t enabled;
- int ret = service_update(service, lcore, 0, &enabled);
- if (ret == 0)
- return enabled;
- return -EINVAL;
-}
-
int32_t
-rte_service_enable_on_lcore(struct rte_service_spec *service, uint32_t lcore)
+rte_service_map_lcore_set(uint32_t id, uint32_t lcore, uint32_t enabled)
{
- uint32_t on = 1;
- return service_update(service, lcore, &on, 0);
+ struct rte_service_spec_impl *s;
+ SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);
+ uint32_t on = enabled > 0;
+ return service_update(&s->spec, lcore, &on, 0);
}
int32_t
-rte_service_disable_on_lcore(struct rte_service_spec *service, uint32_t lcore)
+rte_service_map_lcore_get(uint32_t id, uint32_t lcore)
{
- uint32_t off = 0;
- return service_update(service, lcore, &off, 0);
+ struct rte_service_spec_impl *s;
+ SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);
+ uint32_t enabled;
+ int ret = service_update(&s->spec, lcore, 0, &enabled);
+ if (ret == 0)
+ return enabled;
+ return ret;
}
int32_t rte_service_lcore_reset_all(void)
static int
service_start_stop(void)
{
+ const uint32_t sid = 0;
struct rte_service_spec *service = rte_service_get_by_id(0);
/* is_running() returns if service is running and slcore is mapped */
TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),
"Service core add did not return zero");
- int ret = rte_service_enable_on_lcore(service, slcore_id);
+ int ret = rte_service_map_lcore_set(sid, slcore_id, 1);
TEST_ASSERT_EQUAL(0, ret,
"Enabling service core, expected 0 got %d", ret);
static int
service_lcore_en_dis_able(void)
{
- struct rte_service_spec *s = rte_service_get_by_id(0);
+ const uint32_t sid = 0;
/* expected failure cases */
- TEST_ASSERT_EQUAL(-EINVAL, rte_service_enable_on_lcore(s, 100000),
+ TEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, 100000, 1),
"Enable on invalid core did not fail");
- TEST_ASSERT_EQUAL(-EINVAL, rte_service_disable_on_lcore(s, 100000),
+ TEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, 100000, 0),
"Disable on invalid core did not fail");
/* add service core to allow enabling */
"Add service core failed when not in use before");
/* valid enable */
- TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_id),
+ TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_id, 1),
"Enabling valid service and core failed");
- TEST_ASSERT_EQUAL(1, rte_service_get_enabled_on_lcore(s, slcore_id),
+ TEST_ASSERT_EQUAL(1, rte_service_map_lcore_get(sid, slcore_id),
"Enabled core returned not-enabled");
/* valid disable */
- TEST_ASSERT_EQUAL(0, rte_service_disable_on_lcore(s, slcore_id),
+ TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_id, 0),
"Disabling valid service and lcore failed");
- TEST_ASSERT_EQUAL(0, rte_service_get_enabled_on_lcore(s, slcore_id),
+ TEST_ASSERT_EQUAL(0, rte_service_map_lcore_get(sid, slcore_id),
"Disabled core returned enabled");
/* call remote_launch to verify that app can launch ex-service lcore */
"Register of MT SAFE service failed");
struct rte_service_spec *s = rte_service_get_by_id(0);
+ const uint32_t sid = 0;
TEST_ASSERT_EQUAL(0, rte_service_start(s),
"Starting valid service failed");
- TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_1),
+ TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_1, 1),
"Failed to enable lcore 1 on mt safe service");
- TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_2),
+ TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_2, 1),
"Failed to enable lcore 2 on mt safe service");
rte_service_lcore_start(slcore_1);
rte_service_lcore_start(slcore_2);
service_lcore_start_stop(void)
{
/* start service core and service, create mapping so tick() runs */
+ const uint32_t sid = 0;
struct rte_service_spec *s = rte_service_get_by_id(0);
TEST_ASSERT_EQUAL(0, rte_service_start(s),
"Starting valid service failed");
- TEST_ASSERT_EQUAL(-EINVAL, rte_service_enable_on_lcore(s, slcore_id),
+ TEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, slcore_id, 1),
"Enabling valid service on non-service core must fail");
/* core start */
"Service core start without add should return EINVAL");
TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),
"Service core add did not return zero");
- TEST_ASSERT_EQUAL(0, rte_service_enable_on_lcore(s, slcore_id),
+ TEST_ASSERT_EQUAL(0, rte_service_map_lcore_set(sid, slcore_id, 1),
"Enabling valid service on valid core failed");
TEST_ASSERT_EQUAL(0, rte_service_lcore_start(slcore_id),
"Service core start after add failed");