xref: /titanic_44/usr/src/uts/common/io/igb/igb_log.c (revision 913f7a521f6b98f675dddcd0163e06f0c8e3226f)
1c869993eSxy150489 /*
2c869993eSxy150489  * CDDL HEADER START
3c869993eSxy150489  *
4c869993eSxy150489  * Copyright(c) 2007-2008 Intel Corporation. All rights reserved.
5c869993eSxy150489  * The contents of this file are subject to the terms of the
6c869993eSxy150489  * Common Development and Distribution License (the "License").
7c869993eSxy150489  * You may not use this file except in compliance with the License.
8c869993eSxy150489  *
9c869993eSxy150489  * You can obtain a copy of the license at:
10c869993eSxy150489  *	http://www.opensolaris.org/os/licensing.
11c869993eSxy150489  * See the License for the specific language governing permissions
12c869993eSxy150489  * and limitations under the License.
13c869993eSxy150489  *
14c869993eSxy150489  * When using or redistributing this file, you may do so under the
15c869993eSxy150489  * License only. No other modification of this header is permitted.
16c869993eSxy150489  *
17c869993eSxy150489  * If applicable, add the following below this CDDL HEADER, with the
18c869993eSxy150489  * fields enclosed by brackets "[]" replaced with your own identifying
19c869993eSxy150489  * information: Portions Copyright [yyyy] [name of copyright owner]
20c869993eSxy150489  *
21c869993eSxy150489  * CDDL HEADER END
22c869993eSxy150489  */
23c869993eSxy150489 
24c869993eSxy150489 /*
25c869993eSxy150489  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26c869993eSxy150489  * Use is subject to license terms of the CDDL.
27c869993eSxy150489  */
28c869993eSxy150489 
29c869993eSxy150489 #include "igb_sw.h"
30c869993eSxy150489 
31*913f7a52SYuri Pankov #define	LOG_BUF_LEN	1024
32c869993eSxy150489 
33*913f7a52SYuri Pankov extern int igb_debug;
34*913f7a52SYuri Pankov 
35c869993eSxy150489 void
igb_log(void * arg,igb_debug_t level,const char * fmt,...)36*913f7a52SYuri Pankov igb_log(void *arg, igb_debug_t level, const char *fmt, ...)
37c869993eSxy150489 {
38c869993eSxy150489 	igb_t *igbp = (igb_t *)arg;
39c869993eSxy150489 	char buf[LOG_BUF_LEN];
40*913f7a52SYuri Pankov 	int celevel;
41c869993eSxy150489 	va_list ap;
42c869993eSxy150489 
43c869993eSxy150489 	va_start(ap, fmt);
44c869993eSxy150489 	(void) vsnprintf(buf, sizeof (buf), fmt, ap);
45c869993eSxy150489 	va_end(ap);
46c869993eSxy150489 
47*913f7a52SYuri Pankov 	DTRACE_PROBE2(igb__log, igb_t *, igbp, const char *, buf);
48*913f7a52SYuri Pankov 
49*913f7a52SYuri Pankov 	if (level > igb_debug)
50*913f7a52SYuri Pankov 		return;
51*913f7a52SYuri Pankov 
52*913f7a52SYuri Pankov 	switch (level) {
53*913f7a52SYuri Pankov 	case IGB_LOG_ERROR:
54*913f7a52SYuri Pankov 		celevel = CE_WARN;
55*913f7a52SYuri Pankov 		break;
56*913f7a52SYuri Pankov 	case IGB_LOG_INFO:
57*913f7a52SYuri Pankov 		celevel = CE_NOTE;
58*913f7a52SYuri Pankov 		break;
59*913f7a52SYuri Pankov 	case IGB_LOG_TRACE:
60*913f7a52SYuri Pankov 		celevel = CE_CONT;
61*913f7a52SYuri Pankov 		break;
62*913f7a52SYuri Pankov 	default:
63*913f7a52SYuri Pankov 		celevel = CE_IGNORE;
64c869993eSxy150489 	}
65c869993eSxy150489 
66c869993eSxy150489 	if (igbp != NULL)
67*913f7a52SYuri Pankov 		dev_err(igbp->dip, celevel, "!%s", buf);
68c869993eSxy150489 	else
69*913f7a52SYuri Pankov 		cmn_err(celevel, "!%s", buf);
70c869993eSxy150489 }
71