From f030bff72f8140857388e92204002cb64153459c Mon Sep 17 00:00:00 2001 From: Hemant Agrawal Date: Sat, 11 Jul 2020 13:58:45 +0530 Subject: [PATCH] bitrate: add free function This patch adds support for free function. Signed-off-by: Hemant Agrawal --- app/test/test_bitratestats.c | 4 +++- lib/librte_bitratestats/rte_bitrate.c | 6 ++++++ lib/librte_bitratestats/rte_bitrate.h | 10 +++++++++- lib/librte_bitratestats/rte_bitratestats_version.map | 6 ++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/test/test_bitratestats.c b/app/test/test_bitratestats.c index fb4203c57b..f4a92c9be6 100644 --- a/app/test/test_bitratestats.c +++ b/app/test/test_bitratestats.c @@ -32,12 +32,14 @@ test_stats_bitrate_create(void) return TEST_SUCCESS; } -/* To test free the resources from bitrate_reg test */ +/* To test free the resources from bitrate_create test */ static int test_stats_bitrate_free(void) { int ret = 0; + rte_stats_bitrate_free(bitrate_data); + ret = rte_metrics_deinit(); TEST_ASSERT(ret >= 0, "Test Failed: rte_metrics_deinit failed"); diff --git a/lib/librte_bitratestats/rte_bitrate.c b/lib/librte_bitratestats/rte_bitrate.c index d18152365e..8fd9f47288 100644 --- a/lib/librte_bitratestats/rte_bitrate.c +++ b/lib/librte_bitratestats/rte_bitrate.c @@ -35,6 +35,12 @@ rte_stats_bitrate_create(void) RTE_CACHE_LINE_SIZE); } +void +rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data) +{ + rte_free(bitrate_data); +} + int rte_stats_bitrate_reg(struct rte_stats_bitrates *bitrate_data) { diff --git a/lib/librte_bitratestats/rte_bitrate.h b/lib/librte_bitratestats/rte_bitrate.h index ef10f22ff3..4865929e8f 100644 --- a/lib/librte_bitratestats/rte_bitrate.h +++ b/lib/librte_bitratestats/rte_bitrate.h @@ -27,12 +27,20 @@ struct rte_stats_bitrates; */ struct rte_stats_bitrates *rte_stats_bitrate_create(void); +/** + * Free bitrate statistics structure + * + * @param bitrate_data + * Pointer allocated by rte_stats_bitrate_create() + */ +__rte_experimental +void rte_stats_bitrate_free(struct rte_stats_bitrates *bitrate_data); /** * Register bitrate statistics with the metric library. * * @param bitrate_data - * Pointer allocated by rte_stats_create() + * Pointer allocated by rte_stats_bitrate_create() * * @return * Zero on success diff --git a/lib/librte_bitratestats/rte_bitratestats_version.map b/lib/librte_bitratestats/rte_bitratestats_version.map index 463f78a53a..152730bb4e 100644 --- a/lib/librte_bitratestats/rte_bitratestats_version.map +++ b/lib/librte_bitratestats/rte_bitratestats_version.map @@ -7,3 +7,9 @@ DPDK_21 { local: *; }; + +EXPERIMENTAL { + global: + + rte_stats_bitrate_free; +}; -- 2.20.1