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))
+ if (!rte_service_runstate_get(sw->service_id))
SW_LOG_ERR("Warning: No Service core enabled on service %s\n",
sw->service_name);
rte_service_get_by_id;
rte_service_get_by_name;
rte_service_get_count;
- rte_service_is_running;
rte_service_lcore_add;
rte_service_lcore_count;
rte_service_lcore_count_services;
rte_service_map_lcore_set;
rte_service_probe_capability;
rte_service_reset;
+ rte_service_runstate_get;
+ rte_service_runstate_set;
rte_service_set_stats_enable;
- rte_service_start;
rte_service_start_with_defaults;
- rte_service_stop;
rte_service_unregister;
} DPDK_17.08;
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
- * Enable *service* to run.
+ * Set the runstate of the service.
*
- * This function switches on a service during runtime.
- * @retval 0 The service was successfully started
- */
-int32_t rte_service_start(struct rte_service_spec *service);
-
-/**
- * @warning
- * @b EXPERIMENTAL: this API may change without prior notice
+ * Each service is either running or stopped. Setting a non-zero runstate
+ * enables the service to run, while setting runstate zero disables it.
*
- * Disable *service*.
+ * @param id The id of the service
+ * @param runstate The run state to apply to the service
*
- * Switch off a service, so it is not run until it is *rte_service_start* is
- * called on it.
- * @retval 0 Service successfully switched off
+ * @retval 0 The service was successfully started
+ * @retval -EINVAL Invalid service id
*/
-int32_t rte_service_stop(struct rte_service_spec *service);
+int32_t rte_service_runstate_set(uint32_t id, uint32_t runstate);
/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
- * Returns if *service* is currently running.
- *
- * This function returns true if the service has been started using
- * *rte_service_start*, AND a service core is mapped to the service. This
- * function can be used to ensure that the service will be run.
+ * Get the runstate for the service with *id*. See *rte_service_runstate_set*
+ * for details of runstates.
*
- * @retval 1 Service is currently running, and has a service lcore mapped
- * @retval 0 Service is currently stopped, or no service lcore is mapped
- * @retval -EINVAL Invalid service pointer provided
+ * @retval 1 Service is running
+ * @retval 0 Service is stopped
+ * @retval -EINVAL Invalid service id
*/
-int32_t rte_service_is_running(const struct rte_service_spec *service);
+int32_t rte_service_runstate_get(uint32_t id);
/**
* @warning
return s->spec.capabilities & capability;
}
-int32_t
-rte_service_is_running(const struct rte_service_spec *spec)
-{
- const struct rte_service_spec_impl *impl =
- (const struct rte_service_spec_impl *)spec;
- if (!impl)
- return -EINVAL;
-
- return (impl->runstate == RUNSTATE_RUNNING) &&
- (impl->num_mapped_cores > 0);
-}
-
int32_t
rte_service_component_register(const struct rte_service_spec *spec,
uint32_t *id_ptr)
}
int32_t
-rte_service_start(struct rte_service_spec *service)
+rte_service_runstate_set(uint32_t id, uint32_t runstate)
{
- struct rte_service_spec_impl *s =
- (struct rte_service_spec_impl *)service;
- s->runstate = RUNSTATE_RUNNING;
+ struct rte_service_spec_impl *s;
+ SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);
+
+ if (runstate)
+ s->runstate = RUNSTATE_RUNNING;
+ else
+ s->runstate = RUNSTATE_STOPPED;
+
rte_smp_wmb();
return 0;
}
int32_t
-rte_service_stop(struct rte_service_spec *service)
+rte_service_runstate_get(uint32_t id)
{
- struct rte_service_spec_impl *s =
- (struct rte_service_spec_impl *)service;
- s->runstate = RUNSTATE_STOPPED;
- rte_smp_wmb();
- return 0;
+ struct rte_service_spec_impl *s;
+ SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);
+
+ return (s->runstate == RUNSTATE_RUNNING) && (s->num_mapped_cores > 0);
}
static int32_t
if (lcore_iter >= lcore_count)
lcore_iter = 0;
- ret = rte_service_start(s);
+ ret = rte_service_runstate_set(i, 1);
if (ret)
return -ENOEXEC;
}
rte_service_get_by_id;
rte_service_get_by_name;
rte_service_get_count;
- rte_service_is_running;
rte_service_lcore_add;
rte_service_lcore_count;
rte_service_lcore_count_services;
rte_service_map_lcore_set;
rte_service_probe_capability;
rte_service_reset;
+ rte_service_runstate_get;
+ rte_service_runstate_set;
rte_service_set_stats_enable;
- rte_service_start;
rte_service_start_with_defaults;
- rte_service_stop;
rte_service_unregister;
} DPDK_17.08;
service_start_stop(void)
{
const uint32_t sid = 0;
- struct rte_service_spec *s = rte_service_get_by_id(0);
/* runstate_get() returns if service is running and slcore is mapped */
TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),
TEST_ASSERT_EQUAL(0, ret,
"Enabling service core, expected 0 got %d", ret);
- TEST_ASSERT_EQUAL(0, rte_service_is_running(s),
+ TEST_ASSERT_EQUAL(0, rte_service_runstate_get(sid),
"Error: Service should be stopped");
- TEST_ASSERT_EQUAL(0, rte_service_stop(s),
+ TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),
"Error: Service stopped returned non-zero");
- TEST_ASSERT_EQUAL(0, rte_service_is_running(s),
+ TEST_ASSERT_EQUAL(0, rte_service_runstate_get(sid),
"Error: Service is running - should be stopped");
- TEST_ASSERT_EQUAL(0, rte_service_start(s),
+ TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),
"Error: Service start returned non-zero");
- TEST_ASSERT_EQUAL(1, rte_service_is_running(s),
+ TEST_ASSERT_EQUAL(1, rte_service_runstate_get(sid),
"Error: Service is not running");
return unregister_all();
TEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),
"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),
+ TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),
"Starting valid service failed");
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(1, test_params[1],
"MT Safe service not run by two cores concurrently");
- TEST_ASSERT_EQUAL(0, rte_service_stop(s),
+ TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 0),
"Failed to stop MT Safe service");
unregister_all();
{
/* 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),
+ TEST_ASSERT_EQUAL(0, rte_service_runstate_set(sid, 1),
"Starting valid service failed");
TEST_ASSERT_EQUAL(-EINVAL, rte_service_map_lcore_set(sid, slcore_id, 1),
"Enabling valid service on non-service core must fail");