1 /*
2  * Copyright (c) 2021, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 /* Data types and API definitions in test of NSPE mailbox */
9 
10 #ifndef __TFM_NS_MAILBOX_TEST_H__
11 #define __TFM_NS_MAILBOX_TEST_H__
12 
13 #include <stdint.h>
14 
15 #include "tfm_ns_mailbox.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /**
22  * \brief The structure to hold the statistics result of NSPE mailbox
23  */
24 struct ns_mailbox_stats_res_t {
25     uint8_t avg_nr_slots;               /* The value before the decimal point
26                                          * in the average number of NSPE
27                                          * mailbox slots in use.
28                                          */
29     uint8_t avg_nr_slots_tenths;        /* The first digit value after the
30                                          * decimal point in the average
31                                          * number of NSPE mailbox slots in use.
32                                          */
33 };
34 
35 /**
36  * \brief Initialize the statistics module in TF-M NSPE mailbox.
37  *
38  * \note This function is only available when multi-core tests are enabled.
39  *
40  * \param[in] ns_queue          The NSPE mailbox queue to be tracked.
41  */
42 void tfm_ns_mailbox_tx_stats_init(struct ns_mailbox_queue_t *ns_queue);
43 
44 /**
45  * \brief Re-initialize the statistics module in TF-M NSPE mailbox.
46  *        Clean up statistics data.
47  *
48  * \note This function is only available when multi-core tests are enabled.
49  *
50  * \return \ref MAILBOX_SUCCESS if the operation succeeded, or other return code
51            in case of error
52  */
53 int32_t tfm_ns_mailbox_tx_stats_reinit(void);
54 
55 /**
56  * \brief Update the statistics result of NSPE mailbox message transmission.
57  *
58  * \note This function is only available when multi-core tests are enabled.
59  */
60 void tfm_ns_mailbox_tx_stats_update(void);
61 
62 /**
63  * \brief Calculate the average number of used NS mailbox queue slots each time
64  *        NS task requires a queue slot to submit mailbox message, which is
65  *        recorded in NS mailbox statisitics module.
66  *
67  * \note This function is only available when multi-core tests are enabled.
68  *
69  * \param[in] stats_res         The buffer to be written with
70  *                              \ref ns_mailbox_stats_res_t.
71  */
72 void tfm_ns_mailbox_stats_avg_slot(struct ns_mailbox_stats_res_t *stats_res);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif /* __TFM_NS_MAILBOX_TEST_H__ */
79