1e3cf00d0SUpinder Malhi /* 2e3cf00d0SUpinder Malhi * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved. 3e3cf00d0SUpinder Malhi * 43805eadeSJeff Squyres * This software is available to you under a choice of one of two 53805eadeSJeff Squyres * licenses. You may choose to be licensed under the terms of the GNU 63805eadeSJeff Squyres * General Public License (GPL) Version 2, available from the file 73805eadeSJeff Squyres * COPYING in the main directory of this source tree, or the 83805eadeSJeff Squyres * BSD license below: 93805eadeSJeff Squyres * 103805eadeSJeff Squyres * Redistribution and use in source and binary forms, with or 113805eadeSJeff Squyres * without modification, are permitted provided that the following 123805eadeSJeff Squyres * conditions are met: 133805eadeSJeff Squyres * 143805eadeSJeff Squyres * - Redistributions of source code must retain the above 153805eadeSJeff Squyres * copyright notice, this list of conditions and the following 163805eadeSJeff Squyres * disclaimer. 173805eadeSJeff Squyres * 183805eadeSJeff Squyres * - Redistributions in binary form must reproduce the above 193805eadeSJeff Squyres * copyright notice, this list of conditions and the following 203805eadeSJeff Squyres * disclaimer in the documentation and/or other materials 213805eadeSJeff Squyres * provided with the distribution. 22e3cf00d0SUpinder Malhi * 23e3cf00d0SUpinder Malhi * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24e3cf00d0SUpinder Malhi * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25e3cf00d0SUpinder Malhi * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26e3cf00d0SUpinder Malhi * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27e3cf00d0SUpinder Malhi * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28e3cf00d0SUpinder Malhi * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29e3cf00d0SUpinder Malhi * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30e3cf00d0SUpinder Malhi * SOFTWARE. 31e3cf00d0SUpinder Malhi * 32e3cf00d0SUpinder Malhi */ 33e3cf00d0SUpinder Malhi 34e3cf00d0SUpinder Malhi #ifndef USNIC_LOG_H_ 35e3cf00d0SUpinder Malhi #define USNIC_LOG_H_ 36e3cf00d0SUpinder Malhi 37e3cf00d0SUpinder Malhi #include "usnic.h" 38e3cf00d0SUpinder Malhi 39e3cf00d0SUpinder Malhi extern unsigned int usnic_log_lvl; 40e3cf00d0SUpinder Malhi 41e3cf00d0SUpinder Malhi #define USNIC_LOG_LVL_NONE (0) 42e3cf00d0SUpinder Malhi #define USNIC_LOG_LVL_ERR (1) 43e3cf00d0SUpinder Malhi #define USNIC_LOG_LVL_INFO (2) 44e3cf00d0SUpinder Malhi #define USNIC_LOG_LVL_DBG (3) 45e3cf00d0SUpinder Malhi 46e3cf00d0SUpinder Malhi #define usnic_printk(lvl, args...) \ 47e3cf00d0SUpinder Malhi do { \ 48e3cf00d0SUpinder Malhi printk(lvl "%s:%s:%d: ", DRV_NAME, __func__, \ 49e3cf00d0SUpinder Malhi __LINE__); \ 50e3cf00d0SUpinder Malhi printk(args); \ 51e3cf00d0SUpinder Malhi } while (0) 52e3cf00d0SUpinder Malhi 53e3cf00d0SUpinder Malhi #define usnic_dbg(args...) \ 54e3cf00d0SUpinder Malhi do { \ 55e3cf00d0SUpinder Malhi if (unlikely(usnic_log_lvl >= USNIC_LOG_LVL_DBG)) { \ 56e3cf00d0SUpinder Malhi usnic_printk(KERN_INFO, args); \ 57e3cf00d0SUpinder Malhi } \ 58e3cf00d0SUpinder Malhi } while (0) 59e3cf00d0SUpinder Malhi 60e3cf00d0SUpinder Malhi #define usnic_info(args...) \ 61e3cf00d0SUpinder Malhi do { \ 62e3cf00d0SUpinder Malhi if (usnic_log_lvl >= USNIC_LOG_LVL_INFO) { \ 63e3cf00d0SUpinder Malhi usnic_printk(KERN_INFO, args); \ 64e3cf00d0SUpinder Malhi } \ 65e3cf00d0SUpinder Malhi } while (0) 66e3cf00d0SUpinder Malhi 67e3cf00d0SUpinder Malhi #define usnic_err(args...) \ 68e3cf00d0SUpinder Malhi do { \ 69e3cf00d0SUpinder Malhi if (usnic_log_lvl >= USNIC_LOG_LVL_ERR) { \ 70e3cf00d0SUpinder Malhi usnic_printk(KERN_ERR, args); \ 71e3cf00d0SUpinder Malhi } \ 72e3cf00d0SUpinder Malhi } while (0) 73e3cf00d0SUpinder Malhi #endif /* !USNIC_LOG_H_ */ 74