1230557Sjimharris/*- 2230557Sjimharris * This file is provided under a dual BSD/GPLv2 license. When using or 3230557Sjimharris * redistributing this file, you may do so under either license. 4230557Sjimharris * 5230557Sjimharris * GPL LICENSE SUMMARY 6230557Sjimharris * 7230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 8230557Sjimharris * 9230557Sjimharris * This program is free software; you can redistribute it and/or modify 10230557Sjimharris * it under the terms of version 2 of the GNU General Public License as 11230557Sjimharris * published by the Free Software Foundation. 12230557Sjimharris * 13230557Sjimharris * This program is distributed in the hope that it will be useful, but 14230557Sjimharris * WITHOUT ANY WARRANTY; without even the implied warranty of 15230557Sjimharris * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16230557Sjimharris * General Public License for more details. 17230557Sjimharris * 18230557Sjimharris * You should have received a copy of the GNU General Public License 19230557Sjimharris * along with this program; if not, write to the Free Software 20230557Sjimharris * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. 21230557Sjimharris * The full GNU General Public License is included in this distribution 22230557Sjimharris * in the file called LICENSE.GPL. 23230557Sjimharris * 24230557Sjimharris * BSD LICENSE 25230557Sjimharris * 26230557Sjimharris * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. 27230557Sjimharris * All rights reserved. 28230557Sjimharris * 29230557Sjimharris * Redistribution and use in source and binary forms, with or without 30230557Sjimharris * modification, are permitted provided that the following conditions 31230557Sjimharris * are met: 32230557Sjimharris * 33230557Sjimharris * * Redistributions of source code must retain the above copyright 34230557Sjimharris * notice, this list of conditions and the following disclaimer. 35230557Sjimharris * * Redistributions in binary form must reproduce the above copyright 36230557Sjimharris * notice, this list of conditions and the following disclaimer in 37230557Sjimharris * the documentation and/or other materials provided with the 38230557Sjimharris * distribution. 39230557Sjimharris * 40230557Sjimharris * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 41230557Sjimharris * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 42230557Sjimharris * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 43230557Sjimharris * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 44230557Sjimharris * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 45230557Sjimharris * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 46230557Sjimharris * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 47230557Sjimharris * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 48230557Sjimharris * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 49230557Sjimharris * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 50230557Sjimharris * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 51230557Sjimharris * 52230557Sjimharris * $FreeBSD: releng/11.0/sys/dev/isci/scil/sci_logger.h 231136 2012-02-07 17:43:58Z jimharris $ 53230557Sjimharris */ 54230557Sjimharris#ifndef _SCI_LOGGER_H_ 55230557Sjimharris#define _SCI_LOGGER_H_ 56230557Sjimharris 57230557Sjimharris/** 58230557Sjimharris * @file 59230557Sjimharris * 60230557Sjimharris * @brief This file contains all of the interface methods that can be called 61230557Sjimharris * by an SCI user on the logger object. These methods should be 62230557Sjimharris * utilized to control the amount of information being logged by the 63230557Sjimharris * SCI implementation. 64230557Sjimharris */ 65230557Sjimharris 66230557Sjimharris#ifdef __cplusplus 67230557Sjimharrisextern "C" { 68230557Sjimharris#endif // __cplusplus 69230557Sjimharris 70230557Sjimharris#include <dev/isci/scil/sci_types.h> 71230557Sjimharris 72230557Sjimharris 73230557Sjimharris/* The following is a list of verbosity levels that can be used to enable */ 74230557Sjimharris/* logging for specific log objects. */ 75230557Sjimharris 76230557Sjimharris/** Enable/disable error level logging for the associated logger object(s). */ 77230557Sjimharris#define SCI_LOG_VERBOSITY_ERROR 0x00 78230557Sjimharris 79230557Sjimharris/** Enable/disable warning level logging for the associated logger object(s). */ 80230557Sjimharris#define SCI_LOG_VERBOSITY_WARNING 0x01 81230557Sjimharris 82230557Sjimharris/** 83230557Sjimharris * Enable/disable informative level logging for the associated logger object(s). 84230557Sjimharris */ 85230557Sjimharris#define SCI_LOG_VERBOSITY_INFO 0x02 86230557Sjimharris 87230557Sjimharris/** 88230557Sjimharris * This constant is used to enable function trace (enter/exit) level 89230557Sjimharris * logging for the associated log object(s). 90230557Sjimharris */ 91230557Sjimharris#define SCI_LOG_VERBOSITY_TRACE 0x03 92230557Sjimharris 93230557Sjimharris/** 94230557Sjimharris * This constant is used to enable state tracing information it will emit a 95230557Sjimharris * log message each time a state is entered for the associated log object(s). 96230557Sjimharris */ 97230557Sjimharris#define SCI_LOG_VERBOSITY_STATES 0x04 98230557Sjimharris 99230557Sjimharris#ifdef SCI_LOGGING 100230557Sjimharris 101230557Sjimharris/** 102230557Sjimharris * @brief This method will return the verbosity levels enabled for the object 103230557Sjimharris * listed in the log_object parameter. 104230557Sjimharris * @note Logging must be enabled at compile time in the driver, otherwise 105230557Sjimharris * calling this method has no affect. 106230557Sjimharris * 107230557Sjimharris * @param[in] logger This parameter specifies the logger for which to 108230557Sjimharris * disable the supplied objects/verbosities. For example, 109230557Sjimharris * the framework and core components have different loggers. 110230557Sjimharris * @param[in] log_object This parameter specifies the log object for which 111230557Sjimharris * to retrieve the associated verbosity levels. 112230557Sjimharris * @note This parameter is not a mask, but rather a discrete 113230557Sjimharris * value. 114230557Sjimharris * 115230557Sjimharris * @return This method will return the verbosity levels enabled for the 116230557Sjimharris * supplied log object. 117230557Sjimharris * @retval SCI_LOGGER_VERBOSITY_ERROR This value indicates that the error 118230557Sjimharris * verbosity level was set for the supplied log_object. 119230557Sjimharris * @retval SCI_LOGGER_VERBOSITY_WARNING This value indicates that the warning 120230557Sjimharris * verbosity level was set for the supplied log_object. 121230557Sjimharris * @retval SCI_LOGGER_VERBOSITY_INFO This value indicates that the 122230557Sjimharris * informational verbosity level was set for the supplied log_object. 123230557Sjimharris * @retval SCI_LOGGER_VERBOSITY_TRACE This value indicates that the trace 124230557Sjimharris * verbosity level was set for the supplied log_object. 125230557Sjimharris * @retval SCI_LOGGER_VERBOSITY_STATES This value indicates that the states 126230557Sjimharris * transition verbosity level was set for the supplied log_object 127230557Sjimharris */ 128230557SjimharrisU8 sci_logger_get_verbosity_mask( 129230557Sjimharris SCI_LOGGER_HANDLE_T logger, 130230557Sjimharris U32 log_object 131230557Sjimharris); 132230557Sjimharris 133230557Sjimharris/** 134230557Sjimharris * @brief This method simply returns the log object mask. This mask 135230557Sjimharris * is essentially a list of log objects for which the specified 136230557Sjimharris * level (verbosity) is enabled. 137230557Sjimharris * @note Logging must be enabled at compile time in the driver, otherwise 138230557Sjimharris * calling this method has no affect. 139230557Sjimharris * @note Reserved bits in both the supplied masks shall be ignored. 140230557Sjimharris * 141230557Sjimharris * @param[in] logger This parameter specifies the logger for which to 142230557Sjimharris * disable the supplied objects/verbosities. For example, 143230557Sjimharris * the framework and core components have different loggers. 144230557Sjimharris * @param[in] verbosity This parameter specifies the verbosity for which 145230557Sjimharris * to retrieve the set of enabled log objects. Valid values for 146230557Sjimharris * this parameter are: 147230557Sjimharris * -# SCI_LOGGER_VERBOSITY_ERROR 148230557Sjimharris * -# SCI_LOGGER_VERBOSITY_WARNING 149230557Sjimharris * -# SCI_LOGGER_VERBOSITY_INFO 150230557Sjimharris * -# SCI_LOGGER_VERBOSITY_TRACE 151230557Sjimharris * -# SCI_LOGGER_VERBOSITY_STATES 152230557Sjimharris * @note This parameter is not a mask, but rather a discrete 153230557Sjimharris * value. 154230557Sjimharris * 155230557Sjimharris * @return This method will return the log object mask indicating each of 156230557Sjimharris * the log objects for which logging is enabled at the supplied level. 157230557Sjimharris */ 158230557SjimharrisU32 sci_logger_get_object_mask( 159230557Sjimharris SCI_LOGGER_HANDLE_T logger, 160230557Sjimharris U8 verbosity 161230557Sjimharris); 162230557Sjimharris 163230557Sjimharris/** 164230557Sjimharris * @brief This method will enable each of the supplied log objects in 165230557Sjimharris * log_object_mask for each of the supplied verbosities in 166230557Sjimharris * verbosity_mask. To enable all logging, simply set all bits in 167230557Sjimharris * both the log_object_mask and verbosity_mask. 168230557Sjimharris * @note Logging must be enabled at compile time in the driver, otherwise 169230557Sjimharris * calling this method has no affect. 170230557Sjimharris * @note Reserved bits in both the supplied masks shall be ignored. 171230557Sjimharris * 172230557Sjimharris * @param[in] logger This parameter specifies the logger for which to 173230557Sjimharris * disable the supplied objects/verbosities. For example, 174230557Sjimharris * the framework and core components have different loggers. 175230557Sjimharris * @param[in] log_object_mask This parameter specifies the log objects for 176230557Sjimharris * which to enable logging. 177230557Sjimharris * @param[in] verbosity_mask This parameter specifies the verbosity levels 178230557Sjimharris * at which to enable each log_object. 179230557Sjimharris * 180230557Sjimharris * @return none 181230557Sjimharris */ 182230557Sjimharrisvoid sci_logger_enable( 183230557Sjimharris SCI_LOGGER_HANDLE_T logger, 184230557Sjimharris U32 log_object_mask, 185230557Sjimharris U8 verbosity_mask 186230557Sjimharris); 187230557Sjimharris 188230557Sjimharris/** 189230557Sjimharris * @brief This method will disable each of the supplied log objects in 190230557Sjimharris * log_object_mask for each of the supplied verbosities in 191230557Sjimharris * verbosity_mask. To disable all logging, simply set all bits in 192230557Sjimharris * both the log_object_mask and verbosity_mask. 193230557Sjimharris * @note Logging must be enabled at compile time in the driver, otherwise 194230557Sjimharris * calling this method has no affect. 195230557Sjimharris * @note Reserved bits in both the supplied masks shall be ignored. 196230557Sjimharris * 197230557Sjimharris * @param[in] logger This parameter specifies the logger for which to 198230557Sjimharris * disable the supplied objects/verbosities. For example, 199230557Sjimharris * the framework and core components have different loggers. 200230557Sjimharris * @param[in] log_object_mask This parameter specifies the log objects for 201230557Sjimharris * which to disable logging. 202230557Sjimharris * @param[in] verbosity_mask This parameter specifies the verbosity levels 203230557Sjimharris * at which to disable each log_object. 204230557Sjimharris * 205230557Sjimharris * @return none 206230557Sjimharris */ 207230557Sjimharrisvoid sci_logger_disable( 208230557Sjimharris SCI_LOGGER_HANDLE_T logger, 209230557Sjimharris U32 log_object_mask, 210230557Sjimharris U8 verbosity_mask 211230557Sjimharris); 212230557Sjimharris 213230557Sjimharris 214230557Sjimharris/** 215230557Sjimharris * @brief this macro checks whether it is ok to log. 216230557Sjimharris * 217230557Sjimharris * @param[in] logger This parameter specifies the logger for 218230557Sjimharris * which to disable the supplied 219230557Sjimharris * objects/verbosities. For example, the framework 220230557Sjimharris * and core components have different loggers. 221230557Sjimharris * @param[in] log_object_mask This parameter specifies the log objects for 222230557Sjimharris * which to disable logging. 223230557Sjimharris * @param[in] verbosity_mask This parameter specifies the verbosity levels 224230557Sjimharris * at which to disable each log_object. 225230557Sjimharris * 226230557Sjimharris * @return TRUE or FALSE 227230557Sjimharris */ 228230557SjimharrisBOOL sci_logger_is_enabled( 229230557Sjimharris SCI_LOGGER_HANDLE_T logger, 230230557Sjimharris U32 log_object_mask, 231230557Sjimharris U8 verbosity_mask 232230557Sjimharris); 233230557Sjimharris 234230557Sjimharris 235230557Sjimharris#else // SCI_LOGGING 236230557Sjimharris 237230557Sjimharris#define sci_logger_get_verbosity_mask(logger, log_object) 238230557Sjimharris#define sci_logger_get_object_mask(logger, verbosity) 239230557Sjimharris#define sci_logger_enable(logger, log_object_mask, verbosity_mask) 240230557Sjimharris#define sci_logger_disable(logger, log_object_mask, verbosity_mask) 241230557Sjimharris#define sci_logger_is_enabled(logger, log_object_mask, verbosity_level) 242230557Sjimharris 243230557Sjimharris#endif // SCI_LOGGING 244230557Sjimharris 245230557Sjimharris#ifdef __cplusplus 246230557Sjimharris} 247230557Sjimharris#endif // __cplusplus 248230557Sjimharris 249230557Sjimharris#endif // _SCI_LOGGER_H_ 250230557Sjimharris 251