^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * linux/drivers/scsi/esas2r/esas2r_log.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * For use with ATTO ExpressSAS R6xx SAS/SATA RAID controllers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2001-2013 ATTO Technology, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * (mailto:linuxdrivers@attotech.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * modify it under the terms of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * as published by the Free Software Foundation; either version 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * solely responsible for determining the appropriateness of using and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * distributing the Program and assumes all risks associated with its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * exercise of rights under this Agreement, including but not limited to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * the risks and costs of program errors, damage to or loss of data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * programs or equipment, and unavailability or interruption of operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * DISCLAIMER OF LIABILITY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * You should have received a copy of the GNU General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * along with this program; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * USA.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #ifndef __esas2r_log_h__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define __esas2r_log_h__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ESAS2R_LOG_NONE = 0, /* no events logged */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) ESAS2R_LOG_CRIT = 1, /* critical events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ESAS2R_LOG_WARN = 2, /* warning events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) ESAS2R_LOG_INFO = 3, /* info events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) ESAS2R_LOG_DEBG = 4, /* debugging events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) ESAS2R_LOG_TRCE = 5, /* tracing events */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #ifdef ESAS2R_TRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) ESAS2R_LOG_DFLT = ESAS2R_LOG_TRCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ESAS2R_LOG_DFLT = ESAS2R_LOG_WARN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) __printf(2, 3) int esas2r_log(const long level, const char *format, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) __printf(3, 4) int esas2r_log_dev(const long level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) const struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) const char *format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int esas2r_log_hexdump(const long level,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) const void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) size_t len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * the following macros are provided specifically for debugging and tracing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * messages. esas2r_debug() is provided for generic non-hardware layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * debugging and tracing events. esas2r_hdebug is provided specifically for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * hardware layer debugging and tracing events.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #ifdef ESAS2R_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define esas2r_debug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define esas2r_hdebug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define esas2r_debug(f, args ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define esas2r_hdebug(f, args ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #endif /* ESAS2R_DEBUG */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * the following macros are provided in order to trace the driver and catch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * some more serious bugs. be warned, enabling these macros may *severely*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * impact performance.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #ifdef ESAS2R_TRACE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define esas2r_bugon() \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) esas2r_log(ESAS2R_LOG_TRCE, "esas2r_bugon() called in %s:%d" \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) " - dumping stack and stopping kernel", __func__, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) __LINE__); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) dump_stack(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) BUG(); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #define esas2r_trace_enter() esas2r_log(ESAS2R_LOG_TRCE, "entered %s (%s:%d)", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) __func__, __FILE__, __LINE__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define esas2r_trace_exit() esas2r_log(ESAS2R_LOG_TRCE, "exited %s (%s:%d)", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) __func__, __FILE__, __LINE__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define esas2r_trace(f, args ...) esas2r_log(ESAS2R_LOG_TRCE, "(%s:%s:%d): " \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) f, __func__, __FILE__, __LINE__, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) ## args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define esas2r_bugon()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define esas2r_trace_enter()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define esas2r_trace_exit()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define esas2r_trace(f, args ...)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif /* ESAS2R_TRACE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #endif /* __esas2r_log_h__ */