From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E10BEA48E for ; Fri, 12 Jan 2018 11:27:48 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jan 2018 02:27:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,348,1511856000"; d="scan'208";a="26590550" Received: from silpixa00398672.ir.intel.com ([10.237.223.128]) by orsmga002.jf.intel.com with ESMTP; 12 Jan 2018 02:27:47 -0800 From: Harry van Haaren To: dev@dpdk.org Cc: thomas@monjalon.net, Harry van Haaren Date: Fri, 12 Jan 2018 10:27:18 +0000 Message-Id: <1515752838-56067-3-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515752838-56067-1-git-send-email-harry.van.haaren@intel.com> References: <1507114491-144338-2-git-send-email-harry.van.haaren@intel.com> <1515752838-56067-1-git-send-email-harry.van.haaren@intel.com> Subject: [dpdk-dev] [PATCH v2 3/3] service: add attribute for number of invocations X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Jan 2018 10:27:49 -0000 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 --- v2: - Fix typo in "invocations" --- 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 460dbbf..85e964b 100644 --- a/lib/librte_eal/common/include/rte_service.h +++ b/lib/librte_eal/common/include/rte_service.h @@ -400,6 +400,11 @@ int32_t rte_service_dump(FILE *f, uint32_t id); #define RTE_SERVICE_ATTR_CYCLES 0 /** + * Returns the count of invocations 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 1b54b7e..5f97d85 100644 --- a/lib/librte_eal/common/rte_service.c +++ b/lib/librte_eal/common/rte_service.c @@ -695,6 +695,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 e510643..86b4073 100644 --- a/test/test/test_service_cores.c +++ b/test/test/test_service_cores.c @@ -278,6 +278,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), @@ -298,6 +304,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"); @@ -305,6 +316,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