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