From f7535f4a81fb6015a3373f00f07f6ecb216df01c Mon Sep 17 00:00:00 2001 From: J-Alves Date: Fri, 30 Jul 2021 11:58:41 +0100 Subject: feat(cactus): count requests received Message loop counts the amount of requests received in each core. The counting can be accessed through newly added test command CACTUS_GET_REQ_COUNT_CMD. Added such special command to be able to test delay Schedule Receiver Interrupt, in the context of the notifications feature. Signed-off-by: J-Alves Change-Id: Id0a5a9cf58e10d1221a1a0f0af6264474fe7e020 --- spm/cactus/cactus_tests/cactus_message_loop.c | 42 +++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'spm/cactus/cactus_tests') diff --git a/spm/cactus/cactus_tests/cactus_message_loop.c b/spm/cactus/cactus_tests/cactus_message_loop.c index c24f6fc..750c954 100644 --- a/spm/cactus/cactus_tests/cactus_message_loop.c +++ b/spm/cactus/cactus_tests/cactus_message_loop.c @@ -4,11 +4,20 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#include "cactus_message_loop.h" -#include "cactus_test_cmds.h" -#include #include +#include +#include +#include +#include +#include + +/** + * Counter of the number of handled requests, for each CPU. The number of + * requests can be accessed from another Cactus SP, or from the normal world + * using a special test command. + */ +static uint32_t requests_counter[PLATFORM_CORE_COUNT]; /** * Begin and end of command handler table, respectively. Both symbols defined by @@ -31,6 +40,10 @@ bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret, { uint64_t in_cmd; + /* Get which core it is running from. */ + unsigned int core_pos = platform_get_core_pos( + read_mpidr_el1() & MPID_MASK); + if (cmd_args == NULL || ret == NULL) { ERROR("Invalid arguments passed to %s!\n", __func__); return false; @@ -45,10 +58,33 @@ bool cactus_handle_cmd(smc_ret_values *cmd_args, smc_ret_values *ret, it_cmd++) { if (it_cmd->id == in_cmd) { *ret = it_cmd->fn(cmd_args, mb); + + /* + * Increment the number of requests handled in current + * core. + */ + requests_counter[core_pos]++; + return true; } } + /* Handle special command. */ + if (in_cmd == CACTUS_GET_REQ_COUNT_CMD) { + uint32_t requests_counter_resp; + + /* Read value from array. */ + requests_counter_resp = requests_counter[core_pos]; + VERBOSE("Requests Counter %u, core: %u\n", requests_counter_resp, + core_pos); + + *ret = cactus_success_resp( + ffa_dir_msg_dest(*cmd_args), + ffa_dir_msg_source(*cmd_args), + requests_counter_resp); + return true; + } + *ret = cactus_error_resp(ffa_dir_msg_dest(*cmd_args), ffa_dir_msg_source(*cmd_args), CACTUS_ERROR_UNHANDLED); -- cgit v1.2.3