1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** ThreadX Component */
16 /** */
17 /** Queue */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define TX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "tx_api.h"
28 #include "tx_queue.h"
29 #ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
30 #include "tx_trace.h"
31 #endif
32
33
34 /**************************************************************************/
35 /* */
36 /* FUNCTION RELEASE */
37 /* */
38 /* _tx_queue_performance_info_get PORTABLE C */
39 /* 6.1 */
40 /* AUTHOR */
41 /* */
42 /* William E. Lamie, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function retrieves performance information from the specified */
47 /* queue. */
48 /* */
49 /* INPUT */
50 /* */
51 /* queue_ptr Pointer to queue control block */
52 /* messages_sent Destination for messages sent */
53 /* messages_received Destination for messages received */
54 /* empty_suspensions Destination for number of empty */
55 /* queue suspensions */
56 /* full_suspensions Destination for number of full */
57 /* queue suspensions */
58 /* full_errors Destination for queue full errors */
59 /* returned - no suspension */
60 /* timeouts Destination for number of timeouts*/
61 /* on this queue */
62 /* */
63 /* OUTPUT */
64 /* */
65 /* status Completion status */
66 /* */
67 /* CALLS */
68 /* */
69 /* None */
70 /* */
71 /* CALLED BY */
72 /* */
73 /* Application Code */
74 /* */
75 /* RELEASE HISTORY */
76 /* */
77 /* DATE NAME DESCRIPTION */
78 /* */
79 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
80 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
81 /* resulting in version 6.1 */
82 /* */
83 /**************************************************************************/
_tx_queue_performance_info_get(TX_QUEUE * queue_ptr,ULONG * messages_sent,ULONG * messages_received,ULONG * empty_suspensions,ULONG * full_suspensions,ULONG * full_errors,ULONG * timeouts)84 UINT _tx_queue_performance_info_get(TX_QUEUE *queue_ptr, ULONG *messages_sent, ULONG *messages_received,
85 ULONG *empty_suspensions, ULONG *full_suspensions, ULONG *full_errors, ULONG *timeouts)
86 {
87
88 #ifdef TX_QUEUE_ENABLE_PERFORMANCE_INFO
89
90 TX_INTERRUPT_SAVE_AREA
91 UINT status;
92
93
94 /* Determine if this is a legal request. */
95 if (queue_ptr == TX_NULL)
96 {
97
98 /* Queue pointer is illegal, return error. */
99 status = TX_PTR_ERROR;
100 }
101
102 /* Determine if the queue ID is invalid. */
103 else if (queue_ptr -> tx_queue_id != TX_QUEUE_ID)
104 {
105
106 /* Queue pointer is illegal, return error. */
107 status = TX_PTR_ERROR;
108 }
109 else
110 {
111
112 /* Disable interrupts. */
113 TX_DISABLE
114
115 /* If trace is enabled, insert this event into the trace buffer. */
116 TX_TRACE_IN_LINE_INSERT(TX_TRACE_QUEUE_PERFORMANCE_INFO_GET, queue_ptr, 0, 0, 0, TX_TRACE_QUEUE_EVENTS)
117
118 /* Log this kernel call. */
119 TX_EL_QUEUE_PERFORMANCE_INFO_GET_INSERT
120
121 /* Retrieve all the pertinent information and return it in the supplied
122 destinations. */
123
124 /* Retrieve the number of messages sent to this queue. */
125 if (messages_sent != TX_NULL)
126 {
127
128 *messages_sent = queue_ptr -> tx_queue_performance_messages_sent_count;
129 }
130
131 /* Retrieve the number of messages received from this queue. */
132 if (messages_received != TX_NULL)
133 {
134
135 *messages_received = queue_ptr -> tx_queue_performance_messages_received_count;
136 }
137
138 /* Retrieve the number of empty queue suspensions on this queue. */
139 if (empty_suspensions != TX_NULL)
140 {
141
142 *empty_suspensions = queue_ptr -> tx_queue_performance_empty_suspension_count;
143 }
144
145 /* Retrieve the number of full queue suspensions on this queue. */
146 if (full_suspensions != TX_NULL)
147 {
148
149 *full_suspensions = queue_ptr -> tx_queue_performance_full_suspension_count;
150 }
151
152 /* Retrieve the number of full errors (no suspension!) on this queue. */
153 if (full_errors != TX_NULL)
154 {
155
156 *full_errors = queue_ptr -> tx_queue_performance_full_error_count;
157 }
158
159 /* Retrieve the number of timeouts on this queue. */
160 if (timeouts != TX_NULL)
161 {
162
163 *timeouts = queue_ptr -> tx_queue_performance_timeout_count;
164 }
165
166 /* Restore interrupts. */
167 TX_RESTORE
168
169 /* Return completion status. */
170 status = TX_SUCCESS;
171 }
172 #else
173 UINT status;
174
175
176 /* Access input arguments just for the sake of lint, MISRA, etc. */
177 if (queue_ptr != TX_NULL)
178 {
179
180 /* Not enabled, return error. */
181 status = TX_FEATURE_NOT_ENABLED;
182 }
183 else if (messages_sent != TX_NULL)
184 {
185
186 /* Not enabled, return error. */
187 status = TX_FEATURE_NOT_ENABLED;
188 }
189 else if (messages_received != TX_NULL)
190 {
191
192 /* Not enabled, return error. */
193 status = TX_FEATURE_NOT_ENABLED;
194 }
195 else if (empty_suspensions != TX_NULL)
196 {
197
198 /* Not enabled, return error. */
199 status = TX_FEATURE_NOT_ENABLED;
200 }
201 else if (full_suspensions != TX_NULL)
202 {
203
204 /* Not enabled, return error. */
205 status = TX_FEATURE_NOT_ENABLED;
206 }
207 else if (full_errors != TX_NULL)
208 {
209
210 /* Not enabled, return error. */
211 status = TX_FEATURE_NOT_ENABLED;
212 }
213 else if (timeouts != TX_NULL)
214 {
215
216 /* Not enabled, return error. */
217 status = TX_FEATURE_NOT_ENABLED;
218 }
219 else
220 {
221
222 /* Not enabled, return error. */
223 status = TX_FEATURE_NOT_ENABLED;
224 }
225 #endif
226
227 /* Return completion status. */
228 return(status);
229 }
230
231