19 #ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
21 #define NR_MULTI_CALL_CHILD (NUM_MAILBOX_QUEUE_SLOT * 2)
23 #define NR_MULTI_CALL_CHILD 0
27 #define TEST_CHILD_EVENT_FLAG(x) (uint32_t)(0x1UL << (x))
30 #define MAX_NR_LIGHT_TEST_ROUND 0x200
31 #define MAX_NR_HEAVY_TEST_ROUND 0x20
34 #define MULTI_CALL_LIGHT_TEST_STACK_SIZE 0x200
35 #define MULTI_CALL_HEAVY_TEST_STACK_SIZE 0x300
40 #define ITS_DATA "ITSDataForMultiCore"
41 #define ITS_DATA_LEN sizeof(ITS_DATA)
57 static void multi_client_call_light_test(
struct test_result_t *ret);
58 static void multi_client_call_heavy_test(
struct test_result_t *ret);
59 static void multi_client_call_ooo_test(
struct test_result_t *ret);
61 static struct test_t multi_core_tests[] = {
62 {&multi_client_call_light_test,
63 "MULTI_CLIENT_CALL_LIGHT_TEST",
64 "Multiple outstanding NS PSA client calls lightweight test",
66 {&multi_client_call_heavy_test,
67 "MULTI_CLIENT_CALL_HEAVY_TEST",
68 "Multiple outstanding NS PSA client calls heavyweight test",
70 {&multi_client_call_ooo_test,
71 "MULTI_CLIENT_CALL_OOO_TEST",
72 "Multiple outstanding NS PSA client calls test with out-of-order calls",
81 if (!
sizeof(multi_core_tests)) {
85 list_size = (
sizeof(multi_core_tests) /
sizeof(multi_core_tests[0]));
88 multi_core_tests, list_size, p_test_suite);
91 static void wait_child_thread_completion(
struct test_params *params_array,
98 for (i = 0; i < child_idx; i++) {
118 void *current_thread_handle;
119 uint32_t current_thread_priority, err, total_ticks, total_calls, avg_ticks;
122 struct ns_mailbox_stats_res_t stats_res;
125 tfm_ns_mailbox_tx_stats_init();
128 if (!current_thread_handle) {
129 TEST_FAIL(
"Failed to get current thread ID\r\n");
134 ¤t_thread_priority);
136 TEST_FAIL(
"Failed to get current thread priority\r\n");
153 TEST_FAIL(
"Failed to create a mutex\r\n");
159 params[i].parent_handle = current_thread_handle;
160 params[i].child_idx = i;
163 params[i].is_complete =
false;
164 params[i].is_parent =
false;
170 current_thread_priority);
177 TEST_LOG(
"Totally %d threads for test start\r\n", nr_child + 1);
179 TEST_LOG(
"Each thread run 0x%x rounds tests\r\n", nr_rounds);
186 for (i = 0; i < nr_child; i++) {
191 parent_params.child_idx = nr_child;
193 parent_params.is_parent =
true;
194 test_runner(&parent_params);
197 wait_child_thread_completion(params, nr_child);
206 total_ticks = parent_params.total_ticks;
207 total_calls = parent_params.nr_calls;
210 for (i = 0; i < nr_child; i++) {
216 total_ticks += params[i].total_ticks;
217 total_calls += params[i].nr_calls;
220 tfm_ns_mailbox_stats_avg_slot(&stats_res);
222 TEST_LOG(
"%d.%d NS mailbox queue slots are occupied each time in average.\r\n",
223 stats_res.avg_nr_slots, stats_res.avg_nr_slots_tenths);
225 TEST_LOG(
"Cost %d ticks totally\r\n", total_ticks);
226 avg_ticks = total_ticks / total_calls;
227 total_ticks %= total_calls;
228 TEST_LOG(
"Each PSA client call cost %d.%d ticks in average\r\n", avg_ticks,
229 total_ticks * 10 / total_calls);
245 TEST_LOG(
"Incorrect PSA framework version!\r\n");
256 static void multi_client_call_light_runner(
void *argument)
266 params->
ret = multi_client_call_light_loop(params);
280 static void multi_client_call_light_test(
struct test_result_t *ret)
282 multi_client_call_test(ret, multi_client_call_light_runner,
300 for (i = 0; i < rounds; i++) {
304 TEST_LOG(
"Fail to write ITS asset\r\n");
311 TEST_LOG(
"Fail to read ITS asset\r\n");
318 TEST_LOG(
"Fail to remove ITS asset\r\n");
329 static void multi_client_call_heavy_runner(
void *argument)
340 params->
ret = multi_client_call_heavy_loop(uid, params);
354 static void multi_client_call_heavy_test(
struct test_result_t *ret)
356 multi_client_call_test(ret, multi_client_call_heavy_runner,
362 static void multi_client_call_ooo_runner(
void *argument)
374 params->
ret = multi_client_call_heavy_loop(uid, params);
377 params->
ret = multi_client_call_light_loop(params);
392 static void multi_client_call_ooo_test(
struct test_result_t *ret)
394 multi_client_call_test(ret, multi_client_call_ooo_runner,
#define MULTI_CALL_LIGHT_TEST_STACK_SIZE
void * os_wrapper_thread_new(const char *name, int32_t stack_size, os_wrapper_thread_func func, void *arg, uint32_t priority)
Creates a new thread.
#define PSA_FRAMEWORK_VERSION
uint32_t os_wrapper_mutex_release(void *handle)
Releases the mutex acquired previously.
void(* os_wrapper_thread_func)(void *argument)
#define TEST_FAIL(info_msg)
uint32_t os_wrapper_get_tick(void)
Return RTOS current tick count.
enum test_suite_err_t set_testsuite(const char *name, struct test_t *test_list, uint32_t size, struct test_suite_t *p_ts)
Sets test suite parameters.
void * os_wrapper_thread_get_handle(void)
Gets current thread handle.
psa_status_t psa_its_get(psa_storage_uid_t uid, size_t data_offset, size_t data_size, void *p_data, size_t *p_data_length)
Retrieve data associated with a provided UID.
psa_status_t psa_its_remove(psa_storage_uid_t uid)
Remove the provided uid and its associated data from the storage.
#define NR_MULTI_CALL_CHILD
uint32_t psa_framework_version(void)
Retrieve the version of the PSA Framework API that is implemented.
psa_status_t psa_its_set(psa_storage_uid_t uid, size_t data_length, const void *p_data, psa_storage_create_flags_t create_flags)
Create a new, or modify an existing, uid/value pair.
#define OS_WRAPPER_WAIT_FOREVER
#define MAX_NR_LIGHT_TEST_ROUND
#define NUM_MAILBOX_QUEUE_SLOT
#define MULTI_CALL_HEAVY_TEST_STACK_SIZE
#define TEST_CHILD_EVENT_FLAG(x)
void * os_wrapper_mutex_create(void)
Creates a mutex for mutual exclusion of resources.
void register_testsuite_multi_core_ns_interface(struct test_suite_t *p_test_suite)
Register testsuite for multi-core topology.
uint32_t os_wrapper_thread_get_priority(void *handle, uint32_t *priority)
Gets thread priority.
uint32_t os_wrapper_mutex_delete(void *handle)
Deletes a mutex that is created by os_wrapper_mutex_create()
#define MAX_NR_HEAVY_TEST_ROUND
uint64_t psa_storage_uid_t
uint32_t os_wrapper_mutex_acquire(void *handle, uint32_t timeout)
Acquires a mutex that is created by os_wrapper_mutex_create()
#define PSA_STORAGE_FLAG_NONE
uint32_t psa_storage_create_flags_t
int32_t psa_status_t
Function return status.
uint32_t os_wrapper_thread_wait_flag(uint32_t flags, uint32_t timeout)
Wait for the event flags for synchronizing threads.
uint32_t os_wrapper_thread_set_flag(void *handle, uint32_t flags)
Set the event flags for synchronizing a thread specified by handle.