This commit reworks the service register function to accept
an extra parameter. The parameter is a uint32_t *, which when
provided will be set to the integer service_id that the newly
registered service is represented by.
This is useful for services that wish to validate settings at
a later point in time - they need to know their own service id.
This commit updates the eventdev sw pmd, as well as unit tests
to use the new register API.
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
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",
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",
/* check all ports are set up */
for (i = 0; i < sw->port_count; i++)
/* check all ports are set up */
for (i = 0; i < sw->port_count; i++)
service.callback = sw_sched_service_func;
service.callback_userdata = (void *)dev;
service.callback = sw_sched_service_func;
service.callback_userdata = (void *)dev;
- int32_t ret = rte_service_register(&service);
+ int32_t ret = rte_service_component_register(&service, &sw->service_id);
if (ret) {
SW_LOG_ERR("service register() failed");
return -ENOEXEC;
if (ret) {
SW_LOG_ERR("service register() failed");
return -ENOEXEC;
uint16_t xstats_count_per_qid[RTE_EVENT_MAX_QUEUES_PER_DEV];
uint16_t xstats_offset_for_qid[RTE_EVENT_MAX_QUEUES_PER_DEV];
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];
};
char service_name[SW_PMD_NAME_MAX];
};
rte_eal_devargs_remove;
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
rte_eal_devargs_remove;
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
+ rte_service_component_register;
rte_service_dump;
rte_service_get_by_id;
rte_service_get_by_name;
rte_service_dump;
rte_service_get_by_id;
rte_service_get_by_name;
rte_service_map_lcore_get;
rte_service_map_lcore_set;
rte_service_probe_capability;
rte_service_map_lcore_get;
rte_service_map_lcore_set;
rte_service_probe_capability;
rte_service_reset;
rte_service_set_stats_enable;
rte_service_start;
rte_service_reset;
rte_service_set_stats_enable;
rte_service_start;
* *rte_service_set_coremask*.
*
* @param spec The specification of the service to register
* *rte_service_set_coremask*.
*
* @param spec The specification of the service to register
+ * @param[out] service_id A pointer to a uint32_t, which will be filled in
+ * during registration of the service. It is set to the integers
+ * service number given to the service. This parameter may be NULL.
* @retval 0 Successfully registered the service.
* -EINVAL Attempted to register an invalid service (eg, no callback
* set)
*/
* @retval 0 Successfully registered the service.
* -EINVAL Attempted to register an invalid service (eg, no callback
* set)
*/
-int32_t rte_service_register(const struct rte_service_spec *spec);
+int32_t rte_service_component_register(const struct rte_service_spec *spec,
+ uint32_t *service_id);
-rte_service_register(const struct rte_service_spec *spec)
+rte_service_component_register(const struct rte_service_spec *spec,
+ uint32_t *id_ptr)
{
uint32_t i;
int32_t free_slot = -1;
{
uint32_t i;
int32_t free_slot = -1;
rte_smp_wmb();
rte_service_count++;
rte_smp_wmb();
rte_service_count++;
+ if (id_ptr)
+ *id_ptr = free_slot;
+
rte_eal_devargs_remove;
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
rte_eal_devargs_remove;
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
+ rte_service_component_register;
rte_service_dump;
rte_service_get_by_id;
rte_service_get_by_name;
rte_service_dump;
rte_service_get_by_id;
rte_service_get_by_name;
rte_service_map_lcore_get;
rte_service_map_lcore_set;
rte_service_probe_capability;
rte_service_map_lcore_get;
rte_service_map_lcore_set;
rte_service_probe_capability;
rte_service_reset;
rte_service_set_stats_enable;
rte_service_start;
rte_service_reset;
rte_service_set_stats_enable;
rte_service_start;
struct rte_service_spec service;
memset(&service, 0, sizeof(struct rte_service_spec));
struct rte_service_spec service;
memset(&service, 0, sizeof(struct rte_service_spec));
- TEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(-EINVAL,
+ rte_service_component_register(&service, NULL),
"Invalid callback");
service.callback = dummy_cb;
"Invalid callback");
service.callback = dummy_cb;
- TEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(-EINVAL,
+ rte_service_component_register(&service, NULL),
"Invalid name");
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
"Invalid name");
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
- TEST_ASSERT_EQUAL(0, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),
"Failed to register valid service");
return TEST_SUCCESS;
"Failed to register valid service");
return TEST_SUCCESS;
/* register service */
struct rte_service_spec service;
memset(&service, 0, sizeof(struct rte_service_spec));
/* register service */
struct rte_service_spec service;
memset(&service, 0, sizeof(struct rte_service_spec));
- TEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(-EINVAL,
+ rte_service_component_register(&service, NULL),
"Invalid callback");
service.callback = dummy_cb;
"Invalid callback");
service.callback = dummy_cb;
- TEST_ASSERT_EQUAL(-EINVAL, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(-EINVAL,
+ rte_service_component_register(&service, NULL),
"Invalid name");
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
"Invalid name");
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
- TEST_ASSERT_EQUAL(0, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),
"Failed to register valid service");
/* ensure with dummy services registered returns same ptr as ID */
"Failed to register valid service");
/* ensure with dummy services registered returns same ptr as ID */
service.callback = dummy_cb;
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
service.capabilities |= RTE_SERVICE_CAP_MT_SAFE;
service.callback = dummy_cb;
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
service.capabilities |= RTE_SERVICE_CAP_MT_SAFE;
- TEST_ASSERT_EQUAL(0, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),
"Register of MT SAFE service failed");
/* verify flag is enabled */
"Register of MT SAFE service failed");
/* verify flag is enabled */
memset(&service, 0, sizeof(struct rte_service_spec));
service.callback = dummy_cb;
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
memset(&service, 0, sizeof(struct rte_service_spec));
service.callback = dummy_cb;
snprintf(service.name, sizeof(service.name), DUMMY_SERVICE_NAME);
- TEST_ASSERT_EQUAL(0, rte_service_register(&service),
+ TEST_ASSERT_EQUAL(0, rte_service_component_register(&service, NULL),
"Register of non-MT safe service failed");
/* verify flag is enabled */
"Register of non-MT safe service failed");
/* verify flag is enabled */
service_start_stop(void)
{
const uint32_t sid = 0;
service_start_stop(void)
{
const uint32_t sid = 0;
- struct rte_service_spec *service = rte_service_get_by_id(0);
+ struct rte_service_spec *s = rte_service_get_by_id(0);
- /* is_running() returns if service is running and slcore is mapped */
+ /* runstate_get() 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_map_lcore_set(sid, slcore_id, 1);
TEST_ASSERT_EQUAL(0, ret,
"Enabling service core, expected 0 got %d", ret);
TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),
"Service core add did not return zero");
int ret = rte_service_map_lcore_set(sid, slcore_id, 1);
TEST_ASSERT_EQUAL(0, ret,
"Enabling service core, expected 0 got %d", ret);
- TEST_ASSERT_EQUAL(0, rte_service_is_running(service),
+ TEST_ASSERT_EQUAL(0, rte_service_is_running(s),
"Error: Service should be stopped");
"Error: Service should be stopped");
- TEST_ASSERT_EQUAL(0, rte_service_stop(service),
+ TEST_ASSERT_EQUAL(0, rte_service_stop(s),
"Error: Service stopped returned non-zero");
"Error: Service stopped returned non-zero");
- TEST_ASSERT_EQUAL(0, rte_service_is_running(service),
+ TEST_ASSERT_EQUAL(0, rte_service_is_running(s),
"Error: Service is running - should be stopped");
"Error: Service is running - should be stopped");
- TEST_ASSERT_EQUAL(0, rte_service_start(service),
+ TEST_ASSERT_EQUAL(0, rte_service_start(s),
"Error: Service start returned non-zero");
"Error: Service start returned non-zero");
- TEST_ASSERT_EQUAL(1, rte_service_is_running(service),
+ TEST_ASSERT_EQUAL(1, rte_service_is_running(s),
"Error: Service is not running");
return unregister_all();
"Error: Service is not running");
return unregister_all();
service.callback = dummy_mt_unsafe_cb;
}
service.callback = dummy_mt_unsafe_cb;
}
- TEST_ASSERT_EQUAL(0, rte_service_register(&service),
+ 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);
"Register of MT SAFE service failed");
struct rte_service_spec *s = rte_service_get_by_id(0);