1f11c7f63SJim Harris /*- 2*718cf2ccSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 3*718cf2ccSPedro F. Giffuni * 4f11c7f63SJim Harris * This file is provided under a dual BSD/GPLv2 license. When using or 5f11c7f63SJim Harris * redistributing this file, you may do so under either license. 6f11c7f63SJim Harris * 7f11c7f63SJim Harris * GPL LICENSE SUMMARY 8f11c7f63SJim Harris * 9f11c7f63SJim Harris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 10f11c7f63SJim Harris * 11f11c7f63SJim Harris * This program is free software; you can redistribute it and/or modify 12f11c7f63SJim Harris * it under the terms of version 2 of the GNU General Public License as 13f11c7f63SJim Harris * published by the Free Software Foundation. 14f11c7f63SJim Harris * 15f11c7f63SJim Harris * This program is distributed in the hope that it will be useful, but 16f11c7f63SJim Harris * WITHOUT ANY WARRANTY; without even the implied warranty of 17f11c7f63SJim Harris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18f11c7f63SJim Harris * General Public License for more details. 19f11c7f63SJim Harris * 20f11c7f63SJim Harris * You should have received a copy of the GNU General Public License 21f11c7f63SJim Harris * along with this program; if not, write to the Free Software 22f11c7f63SJim Harris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 23f11c7f63SJim Harris * The full GNU General Public License is included in this distribution 24f11c7f63SJim Harris * in the file called LICENSE.GPL. 25f11c7f63SJim Harris * 26f11c7f63SJim Harris * BSD LICENSE 27f11c7f63SJim Harris * 28f11c7f63SJim Harris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 29f11c7f63SJim Harris * All rights reserved. 30f11c7f63SJim Harris * 31f11c7f63SJim Harris * Redistribution and use in source and binary forms, with or without 32f11c7f63SJim Harris * modification, are permitted provided that the following conditions 33f11c7f63SJim Harris * are met: 34f11c7f63SJim Harris * 35f11c7f63SJim Harris * * Redistributions of source code must retain the above copyright 36f11c7f63SJim Harris * notice, this list of conditions and the following disclaimer. 37f11c7f63SJim Harris * * Redistributions in binary form must reproduce the above copyright 38f11c7f63SJim Harris * notice, this list of conditions and the following disclaimer in 39f11c7f63SJim Harris * the documentation and/or other materials provided with the 40f11c7f63SJim Harris * distribution. 41f11c7f63SJim Harris * 42f11c7f63SJim Harris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43f11c7f63SJim Harris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44f11c7f63SJim Harris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 45f11c7f63SJim Harris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 46f11c7f63SJim Harris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 47f11c7f63SJim Harris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 48f11c7f63SJim Harris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49f11c7f63SJim Harris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50f11c7f63SJim Harris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51f11c7f63SJim Harris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52f11c7f63SJim Harris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53f11c7f63SJim Harris */ 54f11c7f63SJim Harris #ifndef _SCI_LOGGER_H_ 55f11c7f63SJim Harris #define _SCI_LOGGER_H_ 56f11c7f63SJim Harris 57f11c7f63SJim Harris /** 58f11c7f63SJim Harris * @file 59f11c7f63SJim Harris * 60f11c7f63SJim Harris * @brief This file contains all of the interface methods that can be called 61f11c7f63SJim Harris * by an SCI user on the logger object. These methods should be 62f11c7f63SJim Harris * utilized to control the amount of information being logged by the 63f11c7f63SJim Harris * SCI implementation. 64f11c7f63SJim Harris */ 65f11c7f63SJim Harris 66f11c7f63SJim Harris #ifdef __cplusplus 67f11c7f63SJim Harris extern "C" { 68f11c7f63SJim Harris #endif // __cplusplus 69f11c7f63SJim Harris 70f11c7f63SJim Harris #include <dev/isci/scil/sci_types.h> 71f11c7f63SJim Harris 72f11c7f63SJim Harris 73f11c7f63SJim Harris /* The following is a list of verbosity levels that can be used to enable */ 74f11c7f63SJim Harris /* logging for specific log objects. */ 75f11c7f63SJim Harris 76f11c7f63SJim Harris /** Enable/disable error level logging for the associated logger object(s). */ 77f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_ERROR 0x00 78f11c7f63SJim Harris 79f11c7f63SJim Harris /** Enable/disable warning level logging for the associated logger object(s). */ 80f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_WARNING 0x01 81f11c7f63SJim Harris 82f11c7f63SJim Harris /** 83f11c7f63SJim Harris * Enable/disable informative level logging for the associated logger object(s). 84f11c7f63SJim Harris */ 85f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_INFO 0x02 86f11c7f63SJim Harris 87f11c7f63SJim Harris /** 88f11c7f63SJim Harris * This constant is used to enable function trace (enter/exit) level 89f11c7f63SJim Harris * logging for the associated log object(s). 90f11c7f63SJim Harris */ 91f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_TRACE 0x03 92f11c7f63SJim Harris 93f11c7f63SJim Harris /** 94f11c7f63SJim Harris * This constant is used to enable state tracing information it will emit a 95f11c7f63SJim Harris * log message each time a state is entered for the associated log object(s). 96f11c7f63SJim Harris */ 97f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_STATES 0x04 98f11c7f63SJim Harris 99f11c7f63SJim Harris #ifdef SCI_LOGGING 100f11c7f63SJim Harris 101f11c7f63SJim Harris /** 102f11c7f63SJim Harris * @brief This method will return the verbosity levels enabled for the object 103f11c7f63SJim Harris * listed in the log_object parameter. 104f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 105f11c7f63SJim Harris * calling this method has no affect. 106f11c7f63SJim Harris * 107f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 108f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 109f11c7f63SJim Harris * the framework and core components have different loggers. 110f11c7f63SJim Harris * @param[in] log_object This parameter specifies the log object for which 111f11c7f63SJim Harris * to retrieve the associated verbosity levels. 112f11c7f63SJim Harris * @note This parameter is not a mask, but rather a discrete 113f11c7f63SJim Harris * value. 114f11c7f63SJim Harris * 115f11c7f63SJim Harris * @return This method will return the verbosity levels enabled for the 116f11c7f63SJim Harris * supplied log object. 117f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_ERROR This value indicates that the error 118f11c7f63SJim Harris * verbosity level was set for the supplied log_object. 119f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_WARNING This value indicates that the warning 120f11c7f63SJim Harris * verbosity level was set for the supplied log_object. 121f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_INFO This value indicates that the 122f11c7f63SJim Harris * informational verbosity level was set for the supplied log_object. 123f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_TRACE This value indicates that the trace 124f11c7f63SJim Harris * verbosity level was set for the supplied log_object. 125f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_STATES This value indicates that the states 126f11c7f63SJim Harris * transition verbosity level was set for the supplied log_object 127f11c7f63SJim Harris */ 128f11c7f63SJim Harris U8 sci_logger_get_verbosity_mask( 129f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 130f11c7f63SJim Harris U32 log_object 131f11c7f63SJim Harris ); 132f11c7f63SJim Harris 133f11c7f63SJim Harris /** 134f11c7f63SJim Harris * @brief This method simply returns the log object mask. This mask 135f11c7f63SJim Harris * is essentially a list of log objects for which the specified 136f11c7f63SJim Harris * level (verbosity) is enabled. 137f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 138f11c7f63SJim Harris * calling this method has no affect. 139f11c7f63SJim Harris * @note Reserved bits in both the supplied masks shall be ignored. 140f11c7f63SJim Harris * 141f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 142f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 143f11c7f63SJim Harris * the framework and core components have different loggers. 144f11c7f63SJim Harris * @param[in] verbosity This parameter specifies the verbosity for which 145f11c7f63SJim Harris * to retrieve the set of enabled log objects. Valid values for 146f11c7f63SJim Harris * this parameter are: 147f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_ERROR 148f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_WARNING 149f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_INFO 150f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_TRACE 151f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_STATES 152f11c7f63SJim Harris * @note This parameter is not a mask, but rather a discrete 153f11c7f63SJim Harris * value. 154f11c7f63SJim Harris * 155f11c7f63SJim Harris * @return This method will return the log object mask indicating each of 156f11c7f63SJim Harris * the log objects for which logging is enabled at the supplied level. 157f11c7f63SJim Harris */ 158f11c7f63SJim Harris U32 sci_logger_get_object_mask( 159f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 160f11c7f63SJim Harris U8 verbosity 161f11c7f63SJim Harris ); 162f11c7f63SJim Harris 163f11c7f63SJim Harris /** 164f11c7f63SJim Harris * @brief This method will enable each of the supplied log objects in 165f11c7f63SJim Harris * log_object_mask for each of the supplied verbosities in 166f11c7f63SJim Harris * verbosity_mask. To enable all logging, simply set all bits in 167f11c7f63SJim Harris * both the log_object_mask and verbosity_mask. 168f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 169f11c7f63SJim Harris * calling this method has no affect. 170f11c7f63SJim Harris * @note Reserved bits in both the supplied masks shall be ignored. 171f11c7f63SJim Harris * 172f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 173f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 174f11c7f63SJim Harris * the framework and core components have different loggers. 175f11c7f63SJim Harris * @param[in] log_object_mask This parameter specifies the log objects for 176f11c7f63SJim Harris * which to enable logging. 177f11c7f63SJim Harris * @param[in] verbosity_mask This parameter specifies the verbosity levels 178f11c7f63SJim Harris * at which to enable each log_object. 179f11c7f63SJim Harris * 180f11c7f63SJim Harris * @return none 181f11c7f63SJim Harris */ 182f11c7f63SJim Harris void sci_logger_enable( 183f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 184f11c7f63SJim Harris U32 log_object_mask, 185f11c7f63SJim Harris U8 verbosity_mask 186f11c7f63SJim Harris ); 187f11c7f63SJim Harris 188f11c7f63SJim Harris /** 189f11c7f63SJim Harris * @brief This method will disable each of the supplied log objects in 190f11c7f63SJim Harris * log_object_mask for each of the supplied verbosities in 191f11c7f63SJim Harris * verbosity_mask. To disable all logging, simply set all bits in 192f11c7f63SJim Harris * both the log_object_mask and verbosity_mask. 193f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 194f11c7f63SJim Harris * calling this method has no affect. 195f11c7f63SJim Harris * @note Reserved bits in both the supplied masks shall be ignored. 196f11c7f63SJim Harris * 197f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 198f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 199f11c7f63SJim Harris * the framework and core components have different loggers. 200f11c7f63SJim Harris * @param[in] log_object_mask This parameter specifies the log objects for 201f11c7f63SJim Harris * which to disable logging. 202f11c7f63SJim Harris * @param[in] verbosity_mask This parameter specifies the verbosity levels 203f11c7f63SJim Harris * at which to disable each log_object. 204f11c7f63SJim Harris * 205f11c7f63SJim Harris * @return none 206f11c7f63SJim Harris */ 207f11c7f63SJim Harris void sci_logger_disable( 208f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 209f11c7f63SJim Harris U32 log_object_mask, 210f11c7f63SJim Harris U8 verbosity_mask 211f11c7f63SJim Harris ); 212f11c7f63SJim Harris 213f11c7f63SJim Harris 214f11c7f63SJim Harris /** 215f11c7f63SJim Harris * @brief this macro checks whether it is ok to log. 216f11c7f63SJim Harris * 217f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for 218f11c7f63SJim Harris * which to disable the supplied 219f11c7f63SJim Harris * objects/verbosities. For example, the framework 220f11c7f63SJim Harris * and core components have different loggers. 221f11c7f63SJim Harris * @param[in] log_object_mask This parameter specifies the log objects for 222f11c7f63SJim Harris * which to disable logging. 223f11c7f63SJim Harris * @param[in] verbosity_mask This parameter specifies the verbosity levels 224f11c7f63SJim Harris * at which to disable each log_object. 225f11c7f63SJim Harris * 226f11c7f63SJim Harris * @return TRUE or FALSE 227f11c7f63SJim Harris */ 228f11c7f63SJim Harris BOOL sci_logger_is_enabled( 229f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 230f11c7f63SJim Harris U32 log_object_mask, 231f11c7f63SJim Harris U8 verbosity_mask 232f11c7f63SJim Harris ); 233f11c7f63SJim Harris 234f11c7f63SJim Harris 235f11c7f63SJim Harris #else // SCI_LOGGING 236f11c7f63SJim Harris 237f11c7f63SJim Harris #define sci_logger_get_verbosity_mask(logger, log_object) 238f11c7f63SJim Harris #define sci_logger_get_object_mask(logger, verbosity) 239f11c7f63SJim Harris #define sci_logger_enable(logger, log_object_mask, verbosity_mask) 240f11c7f63SJim Harris #define sci_logger_disable(logger, log_object_mask, verbosity_mask) 241f11c7f63SJim Harris #define sci_logger_is_enabled(logger, log_object_mask, verbosity_level) 242f11c7f63SJim Harris 243f11c7f63SJim Harris #endif // SCI_LOGGING 244f11c7f63SJim Harris 245f11c7f63SJim Harris #ifdef __cplusplus 246f11c7f63SJim Harris } 247f11c7f63SJim Harris #endif // __cplusplus 248f11c7f63SJim Harris 249f11c7f63SJim Harris #endif // _SCI_LOGGER_H_ 250f11c7f63SJim Harris 251