xref: /titanic_50/usr/src/uts/common/io/igb/igb_log.c (revision c0dd49bdd68c0d758a67d56f07826f3b45cfc664)
1 /*
2  * CDDL HEADER START
3  *
4  * Copyright(c) 2007-2008 Intel Corporation. All rights reserved.
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at:
10  *	http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When using or redistributing this file, you may do so under the
15  * License only. No other modification of this header is permitted.
16  *
17  * If applicable, add the following below this CDDL HEADER, with the
18  * fields enclosed by brackets "[]" replaced with your own identifying
19  * information: Portions Copyright [yyyy] [name of copyright owner]
20  *
21  * CDDL HEADER END
22  */
23 
24 /*
25  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
26  * Use is subject to license terms of the CDDL.
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include "igb_sw.h"
32 
33 #define	LOG_BUF_LEN	128
34 
35 /*
36  * igb_notice - Report a run-time event (CE_NOTE, to console & log)
37  */
38 void
39 igb_notice(void *arg, const char *fmt, ...)
40 {
41 	igb_t *igbp = (igb_t *)arg;
42 	char buf[LOG_BUF_LEN];
43 	va_list ap;
44 
45 	va_start(ap, fmt);
46 	(void) vsnprintf(buf, sizeof (buf), fmt, ap);
47 	va_end(ap);
48 
49 	if (igbp != NULL)
50 		cmn_err(CE_NOTE, "%s%d: %s", MODULE_NAME, igbp->instance, buf);
51 	else
52 		cmn_err(CE_NOTE, "%s: %s", MODULE_NAME, buf);
53 }
54 
55 /*
56  * igb_log - Log a run-time event (CE_NOTE, to log only)
57  */
58 void
59 igb_log(void *arg, const char *fmt, ...)
60 {
61 	igb_t *igbp = (igb_t *)arg;
62 	char buf[LOG_BUF_LEN];
63 	va_list ap;
64 
65 	va_start(ap, fmt);
66 	(void) vsnprintf(buf, sizeof (buf), fmt, ap);
67 	va_end(ap);
68 
69 	if (igbp != NULL)
70 		cmn_err(CE_NOTE, "!%s%d: %s", MODULE_NAME, igbp->instance, buf);
71 	else
72 		cmn_err(CE_NOTE, "!%s: %s", MODULE_NAME, buf);
73 }
74 
75 /*
76  * igb_error - Log a run-time problem (CE_WARN, to log only)
77  */
78 void
79 igb_error(void *arg, const char *fmt, ...)
80 {
81 	igb_t *igbp = (igb_t *)arg;
82 	char buf[LOG_BUF_LEN];
83 	va_list ap;
84 
85 	va_start(ap, fmt);
86 	(void) vsnprintf(buf, sizeof (buf), fmt, ap);
87 	va_end(ap);
88 
89 	if (igbp != NULL)
90 		cmn_err(CE_WARN, "!%s%d: %s", MODULE_NAME, igbp->instance, buf);
91 	else
92 		cmn_err(CE_WARN, "!%s: %s", MODULE_NAME, buf);
93 }
94