From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Cc: Harry van Haaren <harry.van.haaren@intel.com>
Subject: [dpdk-dev] [PATCH 3/3] service: add attribute for number of invokations
Date: Wed, 4 Oct 2017 11:54:51 +0100 [thread overview]
Message-ID: <1507114491-144338-4-git-send-email-harry.van.haaren@intel.com> (raw)
In-Reply-To: <1507114491-144338-1-git-send-email-harry.van.haaren@intel.com>
This commit adds a new attribute to the service cores attributes
API, which allows the application to retrieve the number of times
that a service-core called the service to perform its action.
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
---
lib/librte_eal/common/include/rte_service.h | 5 +++++
lib/librte_eal/common/rte_service.c | 3 +++
test/test/test_service_cores.c | 16 ++++++++++++++++
3 files changed, 24 insertions(+)
diff --git a/lib/librte_eal/common/include/rte_service.h b/lib/librte_eal/common/include/rte_service.h
index bf7b50b..4684985 100644
--- a/lib/librte_eal/common/include/rte_service.h
+++ b/lib/librte_eal/common/include/rte_service.h
@@ -366,6 +366,11 @@ int32_t rte_service_dump(FILE *f, uint32_t id);
#define RTE_SERVICE_ATTR_CYCLES 0
/**
+ * Returns the count of invokations of this service function
+ */
+#define RTE_SERVICE_ATTR_CALL_COUNT 1
+
+/**
* @warning
* @b EXPERIMENTAL: this API may change without prior notice
*
diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index 3f274f4..fe0b8cf 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -657,6 +657,9 @@ rte_service_attr_get(uint32_t id, uint32_t attr_id, uint32_t *attr_value)
case RTE_SERVICE_ATTR_CYCLES:
*attr_value = s->cycles_spent;
return 0;
+ case RTE_SERVICE_ATTR_CALL_COUNT:
+ *attr_value = s->calls;
+ return 0;
default:
return -EINVAL;
}
diff --git a/test/test/test_service_cores.c b/test/test/test_service_cores.c
index dd3bf75..cabf5de 100644
--- a/test/test/test_service_cores.c
+++ b/test/test/test_service_cores.c
@@ -306,6 +306,12 @@ service_attr_get(void)
"Valid attr_get() call didn't return success");
TEST_ASSERT_EQUAL(0, attr_value,
"attr_get() call didn't set correct cycles (zero)");
+ /* check correct call count */
+ const int attr_calls = RTE_SERVICE_ATTR_CALL_COUNT;
+ TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_calls, &attr_value),
+ "Valid attr_get() call didn't return success");
+ TEST_ASSERT_EQUAL(0, attr_value,
+ "attr_get() call didn't get call count (zero)");
/* Call service to increment cycle count */
TEST_ASSERT_EQUAL(0, rte_service_lcore_add(slcore_id),
@@ -326,6 +332,11 @@ service_attr_get(void)
rte_service_lcore_stop(slcore_id);
+ TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_calls, &attr_value),
+ "Valid attr_get() call didn't return success");
+ TEST_ASSERT_EQUAL(1, (attr_value > 0),
+ "attr_get() call didn't get call count (zero)");
+
TEST_ASSERT_EQUAL(0, rte_service_attr_reset_all(id),
"Valid attr_reset_all() return success");
@@ -333,6 +344,11 @@ service_attr_get(void)
"Valid attr_get() call didn't return success");
TEST_ASSERT_EQUAL(0, attr_value,
"attr_get() call didn't set correct cycles (zero)");
+ /* ensure call count > zero */
+ TEST_ASSERT_EQUAL(0, rte_service_attr_get(id, attr_calls, &attr_value),
+ "Valid attr_get() call didn't return success");
+ TEST_ASSERT_EQUAL(0, (attr_value > 0),
+ "attr_get() call didn't get call count (zero)");
return unregister_all();
}
--
2.7.4
next prev parent reply other threads:[~2017-10-04 10:54 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-04 10:54 [dpdk-dev] [PATCH 0/3] service: add attribute get and reset Harry van Haaren
2017-10-04 10:54 ` [dpdk-dev] [PATCH 1/3] service: add attribute get function Harry van Haaren
2018-01-12 10:27 ` [dpdk-dev] [PATCH v2 " Harry van Haaren
2018-01-12 10:27 ` [dpdk-dev] [PATCH v2 2/3] service: add reset all attributes for service Harry van Haaren
2018-01-12 10:27 ` [dpdk-dev] [PATCH v2 3/3] service: add attribute for number of invocations Harry van Haaren
2018-01-12 11:49 ` [dpdk-dev] [PATCH v2 1/3] service: add attribute get function Thomas Monjalon
2017-10-04 10:54 ` [dpdk-dev] [PATCH 2/3] service: add reset all attributes for service Harry van Haaren
2017-10-04 10:54 ` Harry van Haaren [this message]
2018-01-11 22:42 ` [dpdk-dev] [PATCH 0/3] service: add attribute get and reset Thomas Monjalon
2018-01-12 10:01 ` Van Haaren, Harry
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1507114491-144338-4-git-send-email-harry.van.haaren@intel.com \
--to=harry.van.haaren@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).