Re-enable RMR libary's module tests
[ric-plt/lib/rmr.git] / src / rmr / si / src / rmr_debug_si.c
1 // vim: ts=4 sw=4 noet :
2 /*
3 ==================================================================================
4         Copyright 2021 Samsung Electronics All Rights Reserved.
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10            http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19
20 /*
21         Mnemonic:       rmr_debug_si.c
22         Abstract:       This is the compile point for the debug apis for si
23         version of the rmr library
24
25                                 API functions in this file will provide debug information
26         of rmr
27
28                                 Future:  the API functions can be added with necessity met
29         for the rmr usage.
30
31         Author:         Chung, Seung Wook
32         Date:           12 October 2021
33 */
34
35
36 /*
37         rmr_get_rx_debug_count function will reset debug information of rmr rx queue
38   both drop count and enqueue count of type uint64_t to zero.
39
40   The vctx pointer is the pointer returned by the rmr_init function.
41
42         On success function will return 0 otherwise it is an error.
43   On error, errno will have failure reason, EINVAL.
44 */
45 extern int rmr_reset_rx_debug_count(void *vctx) {
46   uta_ctx_t *ctx;
47   if ((ctx = (uta_ctx_t *)vctx) == NULL) {
48     errno = EINVAL;
49     return EINVAL;
50   }
51   ctx->acc_dcount = 0;
52   ctx->acc_ecount = 0;
53   return 0;
54 }
55
56 /*
57         rmr_get_rx_debug_info function fills debug information of rmr rx status using
58   rmr_rx_debug_t structure type. Debug information for RX status in rmr provides number
59   of messages successfully queued to rmr and number of messages dropped for debug usage.
60
61   The vctx pointer is the pointer returned by the rmr_init function. rx_debug is a pointer
62   to a structure to receive rmr rx status information.
63
64         On success function will return 0 otherwise it is an error.
65   On error, errno will have failure reason, EINVAL.
66
67         CAUTION:
68                 acc_dcount and acc_ecount will count in uint64_t range and will wrap-around when
69     counted more. Two variables are counter thus will only increase.
70 */
71 extern int rmr_get_rx_debug_info(void *vctx, rmr_rx_debug_t *rx_debug) {
72   uta_ctx_t *ctx;
73   if ((ctx = (uta_ctx_t *)vctx) == NULL || rx_debug == NULL ) {
74     errno = EINVAL;
75     return EINVAL;
76   }
77   rx_debug->drop = ctx->acc_dcount;
78   rx_debug->enqueue = ctx->acc_ecount;
79   return 0;
80 }