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 * $FreeBSD$ 55f11c7f63SJim Harris */ 56f11c7f63SJim Harris #ifndef _SCI_LOGGER_H_ 57f11c7f63SJim Harris #define _SCI_LOGGER_H_ 58f11c7f63SJim Harris 59f11c7f63SJim Harris /** 60f11c7f63SJim Harris * @file 61f11c7f63SJim Harris * 62f11c7f63SJim Harris * @brief This file contains all of the interface methods that can be called 63f11c7f63SJim Harris * by an SCI user on the logger object. These methods should be 64f11c7f63SJim Harris * utilized to control the amount of information being logged by the 65f11c7f63SJim Harris * SCI implementation. 66f11c7f63SJim Harris */ 67f11c7f63SJim Harris 68f11c7f63SJim Harris #ifdef __cplusplus 69f11c7f63SJim Harris extern "C" { 70f11c7f63SJim Harris #endif // __cplusplus 71f11c7f63SJim Harris 72f11c7f63SJim Harris #include <dev/isci/scil/sci_types.h> 73f11c7f63SJim Harris 74f11c7f63SJim Harris 75f11c7f63SJim Harris /* The following is a list of verbosity levels that can be used to enable */ 76f11c7f63SJim Harris /* logging for specific log objects. */ 77f11c7f63SJim Harris 78f11c7f63SJim Harris /** Enable/disable error level logging for the associated logger object(s). */ 79f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_ERROR 0x00 80f11c7f63SJim Harris 81f11c7f63SJim Harris /** Enable/disable warning level logging for the associated logger object(s). */ 82f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_WARNING 0x01 83f11c7f63SJim Harris 84f11c7f63SJim Harris /** 85f11c7f63SJim Harris * Enable/disable informative level logging for the associated logger object(s). 86f11c7f63SJim Harris */ 87f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_INFO 0x02 88f11c7f63SJim Harris 89f11c7f63SJim Harris /** 90f11c7f63SJim Harris * This constant is used to enable function trace (enter/exit) level 91f11c7f63SJim Harris * logging for the associated log object(s). 92f11c7f63SJim Harris */ 93f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_TRACE 0x03 94f11c7f63SJim Harris 95f11c7f63SJim Harris /** 96f11c7f63SJim Harris * This constant is used to enable state tracing information it will emit a 97f11c7f63SJim Harris * log message each time a state is entered for the associated log object(s). 98f11c7f63SJim Harris */ 99f11c7f63SJim Harris #define SCI_LOG_VERBOSITY_STATES 0x04 100f11c7f63SJim Harris 101f11c7f63SJim Harris #ifdef SCI_LOGGING 102f11c7f63SJim Harris 103f11c7f63SJim Harris /** 104f11c7f63SJim Harris * @brief This method will return the verbosity levels enabled for the object 105f11c7f63SJim Harris * listed in the log_object parameter. 106f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 107f11c7f63SJim Harris * calling this method has no affect. 108f11c7f63SJim Harris * 109f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 110f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 111f11c7f63SJim Harris * the framework and core components have different loggers. 112f11c7f63SJim Harris * @param[in] log_object This parameter specifies the log object for which 113f11c7f63SJim Harris * to retrieve the associated verbosity levels. 114f11c7f63SJim Harris * @note This parameter is not a mask, but rather a discrete 115f11c7f63SJim Harris * value. 116f11c7f63SJim Harris * 117f11c7f63SJim Harris * @return This method will return the verbosity levels enabled for the 118f11c7f63SJim Harris * supplied log object. 119f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_ERROR This value indicates that the error 120f11c7f63SJim Harris * verbosity level was set for the supplied log_object. 121f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_WARNING This value indicates that the warning 122f11c7f63SJim Harris * verbosity level was set for the supplied log_object. 123f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_INFO This value indicates that the 124f11c7f63SJim Harris * informational verbosity level was set for the supplied log_object. 125f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_TRACE This value indicates that the trace 126f11c7f63SJim Harris * verbosity level was set for the supplied log_object. 127f11c7f63SJim Harris * @retval SCI_LOGGER_VERBOSITY_STATES This value indicates that the states 128f11c7f63SJim Harris * transition verbosity level was set for the supplied log_object 129f11c7f63SJim Harris */ 130f11c7f63SJim Harris U8 sci_logger_get_verbosity_mask( 131f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 132f11c7f63SJim Harris U32 log_object 133f11c7f63SJim Harris ); 134f11c7f63SJim Harris 135f11c7f63SJim Harris /** 136f11c7f63SJim Harris * @brief This method simply returns the log object mask. This mask 137f11c7f63SJim Harris * is essentially a list of log objects for which the specified 138f11c7f63SJim Harris * level (verbosity) is enabled. 139f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 140f11c7f63SJim Harris * calling this method has no affect. 141f11c7f63SJim Harris * @note Reserved bits in both the supplied masks shall be ignored. 142f11c7f63SJim Harris * 143f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 144f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 145f11c7f63SJim Harris * the framework and core components have different loggers. 146f11c7f63SJim Harris * @param[in] verbosity This parameter specifies the verbosity for which 147f11c7f63SJim Harris * to retrieve the set of enabled log objects. Valid values for 148f11c7f63SJim Harris * this parameter are: 149f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_ERROR 150f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_WARNING 151f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_INFO 152f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_TRACE 153f11c7f63SJim Harris * -# SCI_LOGGER_VERBOSITY_STATES 154f11c7f63SJim Harris * @note This parameter is not a mask, but rather a discrete 155f11c7f63SJim Harris * value. 156f11c7f63SJim Harris * 157f11c7f63SJim Harris * @return This method will return the log object mask indicating each of 158f11c7f63SJim Harris * the log objects for which logging is enabled at the supplied level. 159f11c7f63SJim Harris */ 160f11c7f63SJim Harris U32 sci_logger_get_object_mask( 161f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 162f11c7f63SJim Harris U8 verbosity 163f11c7f63SJim Harris ); 164f11c7f63SJim Harris 165f11c7f63SJim Harris /** 166f11c7f63SJim Harris * @brief This method will enable each of the supplied log objects in 167f11c7f63SJim Harris * log_object_mask for each of the supplied verbosities in 168f11c7f63SJim Harris * verbosity_mask. To enable all logging, simply set all bits in 169f11c7f63SJim Harris * both the log_object_mask and verbosity_mask. 170f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 171f11c7f63SJim Harris * calling this method has no affect. 172f11c7f63SJim Harris * @note Reserved bits in both the supplied masks shall be ignored. 173f11c7f63SJim Harris * 174f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 175f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 176f11c7f63SJim Harris * the framework and core components have different loggers. 177f11c7f63SJim Harris * @param[in] log_object_mask This parameter specifies the log objects for 178f11c7f63SJim Harris * which to enable logging. 179f11c7f63SJim Harris * @param[in] verbosity_mask This parameter specifies the verbosity levels 180f11c7f63SJim Harris * at which to enable each log_object. 181f11c7f63SJim Harris * 182f11c7f63SJim Harris * @return none 183f11c7f63SJim Harris */ 184f11c7f63SJim Harris void sci_logger_enable( 185f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 186f11c7f63SJim Harris U32 log_object_mask, 187f11c7f63SJim Harris U8 verbosity_mask 188f11c7f63SJim Harris ); 189f11c7f63SJim Harris 190f11c7f63SJim Harris /** 191f11c7f63SJim Harris * @brief This method will disable each of the supplied log objects in 192f11c7f63SJim Harris * log_object_mask for each of the supplied verbosities in 193f11c7f63SJim Harris * verbosity_mask. To disable all logging, simply set all bits in 194f11c7f63SJim Harris * both the log_object_mask and verbosity_mask. 195f11c7f63SJim Harris * @note Logging must be enabled at compile time in the driver, otherwise 196f11c7f63SJim Harris * calling this method has no affect. 197f11c7f63SJim Harris * @note Reserved bits in both the supplied masks shall be ignored. 198f11c7f63SJim Harris * 199f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for which to 200f11c7f63SJim Harris * disable the supplied objects/verbosities. For example, 201f11c7f63SJim Harris * the framework and core components have different loggers. 202f11c7f63SJim Harris * @param[in] log_object_mask This parameter specifies the log objects for 203f11c7f63SJim Harris * which to disable logging. 204f11c7f63SJim Harris * @param[in] verbosity_mask This parameter specifies the verbosity levels 205f11c7f63SJim Harris * at which to disable each log_object. 206f11c7f63SJim Harris * 207f11c7f63SJim Harris * @return none 208f11c7f63SJim Harris */ 209f11c7f63SJim Harris void sci_logger_disable( 210f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 211f11c7f63SJim Harris U32 log_object_mask, 212f11c7f63SJim Harris U8 verbosity_mask 213f11c7f63SJim Harris ); 214f11c7f63SJim Harris 215f11c7f63SJim Harris 216f11c7f63SJim Harris /** 217f11c7f63SJim Harris * @brief this macro checks whether it is ok to log. 218f11c7f63SJim Harris * 219f11c7f63SJim Harris * @param[in] logger This parameter specifies the logger for 220f11c7f63SJim Harris * which to disable the supplied 221f11c7f63SJim Harris * objects/verbosities. For example, the framework 222f11c7f63SJim Harris * and core components have different loggers. 223f11c7f63SJim Harris * @param[in] log_object_mask This parameter specifies the log objects for 224f11c7f63SJim Harris * which to disable logging. 225f11c7f63SJim Harris * @param[in] verbosity_mask This parameter specifies the verbosity levels 226f11c7f63SJim Harris * at which to disable each log_object. 227f11c7f63SJim Harris * 228f11c7f63SJim Harris * @return TRUE or FALSE 229f11c7f63SJim Harris */ 230f11c7f63SJim Harris BOOL sci_logger_is_enabled( 231f11c7f63SJim Harris SCI_LOGGER_HANDLE_T logger, 232f11c7f63SJim Harris U32 log_object_mask, 233f11c7f63SJim Harris U8 verbosity_mask 234f11c7f63SJim Harris ); 235f11c7f63SJim Harris 236f11c7f63SJim Harris 237f11c7f63SJim Harris #else // SCI_LOGGING 238f11c7f63SJim Harris 239f11c7f63SJim Harris #define sci_logger_get_verbosity_mask(logger, log_object) 240f11c7f63SJim Harris #define sci_logger_get_object_mask(logger, verbosity) 241f11c7f63SJim Harris #define sci_logger_enable(logger, log_object_mask, verbosity_mask) 242f11c7f63SJim Harris #define sci_logger_disable(logger, log_object_mask, verbosity_mask) 243f11c7f63SJim Harris #define sci_logger_is_enabled(logger, log_object_mask, verbosity_level) 244f11c7f63SJim Harris 245f11c7f63SJim Harris #endif // SCI_LOGGING 246f11c7f63SJim Harris 247f11c7f63SJim Harris #ifdef __cplusplus 248f11c7f63SJim Harris } 249f11c7f63SJim Harris #endif // __cplusplus 250f11c7f63SJim Harris 251f11c7f63SJim Harris #endif // _SCI_LOGGER_H_ 252f11c7f63SJim Harris 253