Once the library usage is over, it must be deinitialized which
will free the shared memory reserved during initialization.
Observed an issue while running 'metrics_autotest' continuously
without quiting. For the first run 'metrics_autotest' passes
all test cases but second run onwards first test case fails
because metrics library is already initialized during first run.
Signed-off-by: Harman Kalra <hkalra@marvell.com>
Acked-by: Remy Horton <remy.horton@intel.com>
Acked-by: Reshma Pattan <reshma.pattan@intel.com>
+Deinitialising the library
+--------------------------
+
+Once the library usage is done, it must be deinitialized by calling
+``rte_metrics_deinit()`` which will free the shared memory reserved
+during initialization.
+
+.. code-block:: c
+
+ err = rte_metrics_deinit(void);
+
+If the return value is negative, it means deinitialization failed.
+This function **must** be called from a primary process.
+
Bit-rate statistics library
---------------------------
Bit-rate statistics library
---------------------------
rte_spinlock_init(&stats->lock);
}
rte_spinlock_init(&stats->lock);
}
+int
+rte_metrics_deinit(void)
+{
+ struct rte_metrics_data_s *stats;
+ const struct rte_memzone *memzone;
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return -EINVAL;
+
+ memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
+ if (memzone == NULL)
+ return -EIO;
+
+ stats = memzone->addr;
+ memset(stats, 0, sizeof(struct rte_metrics_data_s));
+
+ return rte_memzone_free(memzone);
+
+}
+
int
rte_metrics_reg_name(const char *name)
{
int
rte_metrics_reg_name(const char *name)
{
#define _RTE_METRICS_H_
#include <stdint.h>
#define _RTE_METRICS_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#ifdef __cplusplus
extern "C" {
*/
void rte_metrics_init(int socket_id);
*/
void rte_metrics_init(int socket_id);
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Deinitialize metric module. This function must be called from
+ * a primary process after all the metrics usage is over, to
+ * release the shared memory.
+ *
+ * @return
+ * -EINVAL - invalid parameter.
+ * -EIO: Error, unable to access metrics shared memory
+ * (rte_metrics_init() not called)
+ * 0 - success
+ */
+__rte_experimental
+int rte_metrics_deinit(void);
+
/**
* Register a metric, making it available as a reporting parameter.
*
/**
* Register a metric, making it available as a reporting parameter.
*
+
+EXPERIMENTAL {
+ global:
+
+ rte_metrics_deinit;
+};