2 * SPDX-License-Identifier: BSD-2-Clause
6 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <dev/isci/isci.h>
38 #include <dev/isci/scil/scif_user_callback.h>
39 #include <dev/isci/scil/scic_user_callback.h>
40 #include <dev/isci/scil/sci_logger.h>
42 #include <machine/stdarg.h>
46 #define WARNING_LEVEL 1
51 isci_log_message(uint32_t verbosity, char *log_message_prefix,
52 char *log_message, ...)
58 if (verbosity > g_isci_debug_level)
61 va_start (argp, log_message);
62 vsnprintf(buffer, sizeof(buffer)-1, log_message, argp);
66 printf("isci: %d:%06d %s %s", (int)tv.tv_sec, (int)tv.tv_usec,
67 log_message_prefix, buffer);
72 #define SCI_ENABLE_LOGGING_ERROR 1
73 #define SCI_ENABLE_LOGGING_WARNING 1
74 #define SCI_ENABLE_LOGGING_INFO 1
75 #define SCI_ENABLE_LOGGING_TRACE 1
76 #define SCI_ENABLE_LOGGING_STATES 1
78 #define ISCI_LOG_MESSAGE( \
89 if (!sci_logger_is_enabled(logger_object, log_object_mask, verbosity)) \
92 va_start (argp, log_message); \
93 vsnprintf(buffer, sizeof(buffer)-1, log_message, argp); \
96 /* prepend the "object:verbosity_level:" */ \
97 isci_log_message(verbosity, log_message_prefix, buffer); \
99 #endif /* SCI_LOGGING */
102 #ifdef SCI_ENABLE_LOGGING_ERROR
104 * @brief In this method the user is expected to log the supplied
105 * error information. The user must be capable of handling variable
106 * length argument lists and should consider prepending the fact
107 * that this is an error from the framework.
109 * @param[in] logger_object This parameter specifies the logger object
110 * associated with this message.
111 * @param[in] log_object_mask This parameter specifies the log objects
112 * for which this message is being generated.
113 * @param[in] log_message This parameter specifies the message to be logged.
117 void scif_cb_logger_log_error(SCI_LOGGER_HANDLE_T logger_object,
118 uint32_t log_object_mask, char *log_message, ...)
121 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
122 SCI_LOG_VERBOSITY_ERROR, "FRAMEWORK: ERROR: ");
126 #ifdef SCI_ENABLE_LOGGING_WARNING
128 * @brief In this method the user is expected to log the supplied warning
129 * information. The user must be capable of handling variable
130 * length argument lists and should consider prepending the fact
131 * that this is a warning from the framework.
133 * @param[in] logger_object This parameter specifies the logger object
134 * associated with this message.
135 * @param[in] log_object_mask This parameter specifies the log objects
136 * for which this message is being generated.
137 * @param[in] log_message This parameter specifies the message to be logged.
142 scif_cb_logger_log_warning(SCI_LOGGER_HANDLE_T logger_object,
143 uint32_t log_object_mask, char *log_message, ...)
146 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
147 SCI_LOG_VERBOSITY_WARNING, "FRAMEWORK: WARNING: ");
151 #ifdef SCI_ENABLE_LOGGING_INFO
153 * @brief In this method the user is expected to log the supplied debug
154 * information. The user must be capable of handling variable
155 * length argument lists and should consider prepending the fact
156 * that this is a debug message from the framework.
158 * @param[in] logger_object This parameter specifies the logger object
159 * associated with this message.
160 * @param[in] log_object_mask This parameter specifies the log objects
161 * for which this message is being generated.
162 * @param[in] log_message This parameter specifies the message to be logged.
167 scif_cb_logger_log_info(SCI_LOGGER_HANDLE_T logger_object,
168 uint32_t log_object_mask, char *log_message, ...)
171 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
172 SCI_LOG_VERBOSITY_INFO, "FRAMEWORK: INFO: ");
176 #ifdef SCI_ENABLE_LOGGING_TRACE
178 * @brief In this method the user is expected to log the supplied function
179 * trace information. The user must be capable of handling variable
180 * length argument lists and should consider prepending the fact
181 * that this is a function trace (i.e. entry/exit) message from the
184 * @param[in] logger_object This parameter specifies the logger object
185 * associated with this message.
186 * @param[in] log_object_mask This parameter specifies the log objects
187 * for which this message is being generated.
188 * @param[in] log_message This parameter specifies the message to be logged.
193 scif_cb_logger_log_trace(SCI_LOGGER_HANDLE_T logger_object,
194 uint32_t log_object_mask, char *log_message, ...)
197 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
198 SCI_LOG_VERBOSITY_TRACE, "FRAMEWORK: TRACE: ");
202 #ifdef SCI_ENABLE_LOGGING_STATES
204 * @brief In this method the user is expected to log the supplied function
205 * state transition information. The user must be capable of handling
206 * variable length argument lists and should consider prepending the
207 * fact that this is a function trace (i.e. entry/exit) message from
210 * @param[in] logger_object This parameter specifies the logger object
211 * associated with this message.
212 * @param[in] log_object_mask This parameter specifies the log objects
213 * for which this message is being generated.
214 * @param[in] log_message This parameter specifies the message to be logged.
219 scif_cb_logger_log_states(SCI_LOGGER_HANDLE_T logger_object,
220 uint32_t log_object_mask, char *log_message, ...)
223 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
224 SCI_LOG_VERBOSITY_STATES, "FRAMEWORK: STATE TRANSITION: ");
228 #ifdef SCI_ENABLE_LOGGING_ERROR
230 * @brief In this method the user is expected to log the supplied
231 * error information. The user must be capable of handling variable
232 * length argument lists and should consider prepending the fact
233 * that this is an error from the core.
235 * @param[in] logger_object This parameter specifies the logger object
236 * associated with this message.
237 * @param[in] log_object_mask This parameter specifies the log objects
238 * for which this message is being generated.
239 * @param[in] log_message This parameter specifies the message to be logged.
244 scic_cb_logger_log_error(SCI_LOGGER_HANDLE_T logger_object,
245 uint32_t log_object_mask, char *log_message, ...)
248 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
249 SCI_LOG_VERBOSITY_ERROR, "CORE: ERROR: ");
253 #ifdef SCI_ENABLE_LOGGING_WARNING
255 * @brief In this method the user is expected to log the supplied warning
256 * information. The user must be capable of handling variable
257 * length argument lists and should consider prepending the fact
258 * that this is a warning from the core.
260 * @param[in] logger_object This parameter specifies the logger object
261 * associated with this message.
262 * @param[in] log_object_mask This parameter specifies the log objects
263 * for which this message is being generated.
264 * @param[in] log_message This parameter specifies the message to be logged.
269 scic_cb_logger_log_warning(SCI_LOGGER_HANDLE_T logger_object,
270 uint32_t log_object_mask, char *log_message, ...)
273 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
274 SCI_LOG_VERBOSITY_WARNING, "CORE: WARNING: ");
278 #ifdef SCI_ENABLE_LOGGING_INFO
280 * @brief In this method the user is expected to log the supplied debug
281 * information. The user must be capable of handling variable
282 * length argument lists and should consider prepending the fact
283 * that this is a debug message from the core.
285 * @param[in] logger_object This parameter specifies the logger object
286 * associated with this message.
287 * @param[in] log_object_mask This parameter specifies the log objects
288 * for which this message is being generated.
289 * @param[in] log_message This parameter specifies the message to be logged.
294 scic_cb_logger_log_info(SCI_LOGGER_HANDLE_T logger_object,
295 uint32_t log_object_mask, char *log_message, ...)
298 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
299 SCI_LOG_VERBOSITY_INFO, "CORE: INFO: ");
303 #ifdef SCI_ENABLE_LOGGING_TRACE
305 * @brief In this method the user is expected to log the supplied function
306 * trace information. The user must be capable of handling variable
307 * length argument lists and should consider prepending the fact
308 * that this is a function trace (i.e. entry/exit) message from the
311 * @param[in] logger_object This parameter specifies the logger object
312 * associated with this message.
313 * @param[in] log_object_mask This parameter specifies the log objects
314 * for which this message is being generated.
315 * @param[in] log_message This parameter specifies the message to be logged.
320 scic_cb_logger_log_trace(SCI_LOGGER_HANDLE_T logger_object,
321 uint32_t log_object_mask, char *log_message, ...)
324 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
325 SCI_LOG_VERBOSITY_TRACE, "CORE: TRACE: ");
329 #ifdef SCI_ENABLE_LOGGING_STATES
331 * @brief In this method the user is expected to log the supplied function
332 * state transition information. The user must be capable of handling
333 * variable length argument lists and should consider prepending the
334 * fact that this is a function trace (i.e. entry/exit) message from
337 * @param[in] logger_object This parameter specifies the logger object
338 * associated with this message.
339 * @param[in] log_object_mask This parameter specifies the log objects
340 * for which this message is being generated.
341 * @param[in] log_message This parameter specifies the message to be logged.
346 scic_cb_logger_log_states(SCI_LOGGER_HANDLE_T logger_object,
347 uint32_t log_object_mask, char *log_message, ...)
350 ISCI_LOG_MESSAGE(logger_object, log_object_mask, log_message,
351 SCI_LOG_VERBOSITY_STATES, "CORE: STATE TRANSITION: ");