126780d9eSBradley Grove /* 226780d9eSBradley Grove * linux/drivers/scsi/esas2r/esas2r_log.h 326780d9eSBradley Grove * For use with ATTO ExpressSAS R6xx SAS/SATA RAID controllers 426780d9eSBradley Grove * 526780d9eSBradley Grove * Copyright (c) 2001-2013 ATTO Technology, Inc. 626780d9eSBradley Grove * (mailto:linuxdrivers@attotech.com) 726780d9eSBradley Grove * 826780d9eSBradley Grove * This program is free software; you can redistribute it and/or 926780d9eSBradley Grove * modify it under the terms of the GNU General Public License 1026780d9eSBradley Grove * as published by the Free Software Foundation; either version 2 1126780d9eSBradley Grove * of the License, or (at your option) any later version. 1226780d9eSBradley Grove * 1326780d9eSBradley Grove * This program is distributed in the hope that it will be useful, 1426780d9eSBradley Grove * but WITHOUT ANY WARRANTY; without even the implied warranty of 1526780d9eSBradley Grove * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1626780d9eSBradley Grove * GNU General Public License for more details. 1726780d9eSBradley Grove * 1826780d9eSBradley Grove * NO WARRANTY 1926780d9eSBradley Grove * THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR 2026780d9eSBradley Grove * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT 2126780d9eSBradley Grove * LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, 2226780d9eSBradley Grove * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is 2326780d9eSBradley Grove * solely responsible for determining the appropriateness of using and 2426780d9eSBradley Grove * distributing the Program and assumes all risks associated with its 2526780d9eSBradley Grove * exercise of rights under this Agreement, including but not limited to 2626780d9eSBradley Grove * the risks and costs of program errors, damage to or loss of data, 2726780d9eSBradley Grove * programs or equipment, and unavailability or interruption of operations. 2826780d9eSBradley Grove * 2926780d9eSBradley Grove * DISCLAIMER OF LIABILITY 3026780d9eSBradley Grove * NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY 3126780d9eSBradley Grove * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3226780d9eSBradley Grove * DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND 3326780d9eSBradley Grove * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 3426780d9eSBradley Grove * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 3526780d9eSBradley Grove * USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED 3626780d9eSBradley Grove * HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 3726780d9eSBradley Grove * 3826780d9eSBradley Grove * You should have received a copy of the GNU General Public License 3926780d9eSBradley Grove * along with this program; if not, write to the Free Software 4026780d9eSBradley Grove * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 4126780d9eSBradley Grove * USA. 4226780d9eSBradley Grove */ 4326780d9eSBradley Grove 4426780d9eSBradley Grove #ifndef __esas2r_log_h__ 4526780d9eSBradley Grove #define __esas2r_log_h__ 4626780d9eSBradley Grove 4726780d9eSBradley Grove struct device; 4826780d9eSBradley Grove 4926780d9eSBradley Grove enum { 5026780d9eSBradley Grove ESAS2R_LOG_NONE = 0, /* no events logged */ 5126780d9eSBradley Grove ESAS2R_LOG_CRIT = 1, /* critical events */ 5226780d9eSBradley Grove ESAS2R_LOG_WARN = 2, /* warning events */ 5326780d9eSBradley Grove ESAS2R_LOG_INFO = 3, /* info events */ 5426780d9eSBradley Grove ESAS2R_LOG_DEBG = 4, /* debugging events */ 5526780d9eSBradley Grove ESAS2R_LOG_TRCE = 5, /* tracing events */ 5626780d9eSBradley Grove 5726780d9eSBradley Grove #ifdef ESAS2R_TRACE 5826780d9eSBradley Grove ESAS2R_LOG_DFLT = ESAS2R_LOG_TRCE 5926780d9eSBradley Grove #else 6026780d9eSBradley Grove ESAS2R_LOG_DFLT = ESAS2R_LOG_WARN 6126780d9eSBradley Grove #endif 6226780d9eSBradley Grove }; 6326780d9eSBradley Grove 6426780d9eSBradley Grove int esas2r_log(const long level, const char *format, ...); 6526780d9eSBradley Grove int esas2r_log_dev(const long level, 6626780d9eSBradley Grove const struct device *dev, 6726780d9eSBradley Grove const char *format, 6826780d9eSBradley Grove ...); 6926780d9eSBradley Grove int esas2r_log_hexdump(const long level, 7026780d9eSBradley Grove const void *buf, 7126780d9eSBradley Grove size_t len); 7226780d9eSBradley Grove 7326780d9eSBradley Grove /* 7426780d9eSBradley Grove * the following macros are provided specifically for debugging and tracing 7526780d9eSBradley Grove * messages. esas2r_debug() is provided for generic non-hardware layer 7626780d9eSBradley Grove * debugging and tracing events. esas2r_hdebug is provided specifically for 7726780d9eSBradley Grove * hardware layer debugging and tracing events. 7826780d9eSBradley Grove */ 7926780d9eSBradley Grove 8026780d9eSBradley Grove #ifdef ESAS2R_DEBUG 8126780d9eSBradley Grove #define esas2r_debug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args) 8226780d9eSBradley Grove #define esas2r_hdebug(f, args ...) esas2r_log(ESAS2R_LOG_DEBG, f, ## args) 8326780d9eSBradley Grove #else 8426780d9eSBradley Grove #define esas2r_debug(f, args ...) 8526780d9eSBradley Grove #define esas2r_hdebug(f, args ...) 8626780d9eSBradley Grove #endif /* ESAS2R_DEBUG */ 8726780d9eSBradley Grove 8826780d9eSBradley Grove /* 8926780d9eSBradley Grove * the following macros are provided in order to trace the driver and catch 9026780d9eSBradley Grove * some more serious bugs. be warned, enabling these macros may *severely* 9126780d9eSBradley Grove * impact performance. 9226780d9eSBradley Grove */ 9326780d9eSBradley Grove 9426780d9eSBradley Grove #ifdef ESAS2R_TRACE 9526780d9eSBradley Grove #define esas2r_bugon() \ 9626780d9eSBradley Grove do { \ 9726780d9eSBradley Grove esas2r_log(ESAS2R_LOG_TRCE, "esas2r_bugon() called in %s:%d" \ 9826780d9eSBradley Grove " - dumping stack and stopping kernel", __func__, \ 9926780d9eSBradley Grove __LINE__); \ 10026780d9eSBradley Grove dump_stack(); \ 10126780d9eSBradley Grove BUG(); \ 10226780d9eSBradley Grove } while (0) 10326780d9eSBradley Grove 10426780d9eSBradley Grove #define esas2r_trace_enter() esas2r_log(ESAS2R_LOG_TRCE, "entered %s (%s:%d)", \ 10526780d9eSBradley Grove __func__, __FILE__, __LINE__) 10626780d9eSBradley Grove #define esas2r_trace_exit() esas2r_log(ESAS2R_LOG_TRCE, "exited %s (%s:%d)", \ 10726780d9eSBradley Grove __func__, __FILE__, __LINE__) 10826780d9eSBradley Grove #define esas2r_trace(f, args ...) esas2r_log(ESAS2R_LOG_TRCE, "(%s:%s:%d): " \ 10926780d9eSBradley Grove f, __func__, __FILE__, __LINE__, \ 11026780d9eSBradley Grove ## args) 11126780d9eSBradley Grove #else 11226780d9eSBradley Grove #define esas2r_bugon() 11326780d9eSBradley Grove #define esas2r_trace_enter() 11426780d9eSBradley Grove #define esas2r_trace_exit() 11526780d9eSBradley Grove #define esas2r_trace(f, args ...) 11626780d9eSBradley Grove #endif /* ESAS2R_TRACE */ 11726780d9eSBradley Grove 11826780d9eSBradley Grove #endif /* __esas2r_log_h__ */ 119