1/*
2 * Copyright (c) 2013, Cisco Systems, Inc. All rights reserved.
3 *
4 * This program is free software; you may redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15 * SOFTWARE.
16 *
17 */
18
19#ifndef USNIC_LOG_H_
20#define USNIC_LOG_H_
21
22#include "usnic.h"
23
24extern unsigned int usnic_log_lvl;
25
26#define USNIC_LOG_LVL_NONE		(0)
27#define USNIC_LOG_LVL_ERR		(1)
28#define USNIC_LOG_LVL_INFO		(2)
29#define USNIC_LOG_LVL_DBG		(3)
30
31#define usnic_printk(lvl, args...) \
32	do { \
33		printk(lvl "%s:%s:%d: ", DRV_NAME, __func__, \
34				__LINE__); \
35		printk(args); \
36	} while (0)
37
38#define usnic_dbg(args...) \
39	do { \
40		if (unlikely(usnic_log_lvl >= USNIC_LOG_LVL_DBG)) { \
41			usnic_printk(KERN_INFO, args); \
42	} \
43} while (0)
44
45#define usnic_info(args...) \
46do { \
47	if (usnic_log_lvl >= USNIC_LOG_LVL_INFO) { \
48			usnic_printk(KERN_INFO, args); \
49	} \
50} while (0)
51
52#define usnic_err(args...) \
53	do { \
54		if (usnic_log_lvl >= USNIC_LOG_LVL_ERR) { \
55			usnic_printk(KERN_ERR, args); \
56		} \
57	} while (0)
58#endif /* !USNIC_LOG_H_ */
59