int32_t rte_service_attr_get(uint32_t id, uint32_t attr_id,
uint32_t *attr_value);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Reset all attribute values of a service.
+ *
+ * @param id The service to reset all statistics of
+ * @retval 0 Successfully reset attributes
+ * -EINVAL Invalid service id provided
+ */
+int32_t rte_service_attr_reset_all(uint32_t id);
+
#ifdef __cplusplus
}
#endif
if (s->calls != 0)
calls = s->calls;
+ if (reset) {
+ s->cycles_spent = 0;
+ s->calls = 0;
+ return;
+ }
+
fprintf(f, " %s: stats %d\tcalls %"PRIu64"\tcycles %"
PRIu64"\tavg: %"PRIu64"\n",
s->spec.name, service_stats_enabled(s), s->calls,
s->cycles_spent, s->cycles_spent / calls);
+}
- if (reset) {
- s->cycles_spent = 0;
- s->calls = 0;
- }
+int32_t
+rte_service_attr_reset_all(uint32_t id)
+{
+ struct rte_service_spec_impl *s;
+ SERVICE_VALID_GET_OR_ERR_RET(id, s, -EINVAL);
+
+ int reset = 1;
+ rte_service_dump_one(NULL, s, 0, reset);
+ return 0;
}
static void
for (i = 0; i < RTE_SERVICE_NUM_MAX; i++) {
if (!service_valid(i))
continue;
- uint32_t reset = 1;
+ uint32_t reset = 0;
rte_service_dump_one(f, &rte_services[i], total_cycles, reset);
}
if (lcore_config[i].core_role != ROLE_SERVICE)
continue;
- uint32_t reset = 1;
+ uint32_t reset = 0;
service_dump_calls_per_lcore(f, i, reset);
}
rte_eal_hotplug_add;
rte_eal_hotplug_remove;
rte_service_attr_get;
+ rte_service_attr_reset_all;
rte_service_component_register;
rte_service_component_unregister;
rte_service_component_runstate_set;
static int
service_attr_get(void)
{
+ /* ensure all services unregistered so cycle counts are zero */
+ unregister_all();
+
struct rte_service_spec service;
memset(&service, 0, sizeof(struct rte_service_spec));
service.callback = dummy_cb;
rte_service_lcore_stop(slcore_id);
+ TEST_ASSERT_EQUAL(0, rte_service_attr_reset_all(id),
+ "Valid attr_reset_all() return success");
+
+ TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_id, &attr_value),
+ "Valid attr_get() call didn't return success");
+ TEST_ASSERT_EQUAL(0, attr_value,
+ "attr_get() call didn't set correct cycles (zero)");
+
return unregister_all();
}