xref: /onnv-gate/usr/src/uts/common/crypto/io/dca_debug.c (revision 906:1b5a12bcb15b)
1*906Sgm89044 /*
2*906Sgm89044  * CDDL HEADER START
3*906Sgm89044  *
4*906Sgm89044  * The contents of this file are subject to the terms of the
5*906Sgm89044  * Common Development and Distribution License (the "License").
6*906Sgm89044  * You may not use this file except in compliance with the License.
7*906Sgm89044  *
8*906Sgm89044  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*906Sgm89044  * or http://www.opensolaris.org/os/licensing.
10*906Sgm89044  * See the License for the specific language governing permissions
11*906Sgm89044  * and limitations under the License.
12*906Sgm89044  *
13*906Sgm89044  * When distributing Covered Code, include this CDDL HEADER in each
14*906Sgm89044  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*906Sgm89044  * If applicable, add the following below this CDDL HEADER, with the
16*906Sgm89044  * fields enclosed by brackets "[]" replaced with your own identifying
17*906Sgm89044  * information: Portions Copyright [yyyy] [name of copyright owner]
18*906Sgm89044  *
19*906Sgm89044  * CDDL HEADER END
20*906Sgm89044  */
21*906Sgm89044 
22*906Sgm89044 /*
23*906Sgm89044  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*906Sgm89044  * Use is subject to license terms.
25*906Sgm89044  */
26*906Sgm89044 
27*906Sgm89044 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*906Sgm89044 
29*906Sgm89044 /*
30*906Sgm89044  * Deimos - cryptographic acceleration based upon Broadcom 582x.
31*906Sgm89044  */
32*906Sgm89044 
33*906Sgm89044 #include <sys/types.h>
34*906Sgm89044 #include <sys/ddi.h>
35*906Sgm89044 #include <sys/sunddi.h>
36*906Sgm89044 #include <sys/cmn_err.h>
37*906Sgm89044 #include <sys/varargs.h>
38*906Sgm89044 #include <sys/crypto/dca.h>
39*906Sgm89044 
40*906Sgm89044 /*
41*906Sgm89044  * Debugging and messaging.
42*906Sgm89044  */
43*906Sgm89044 #if DEBUG
44*906Sgm89044 static int dca_debug = 0;
45*906Sgm89044 
46*906Sgm89044 void
dca_dprintf(dca_t * dca,int level,const char * fmt,...)47*906Sgm89044 dca_dprintf(dca_t *dca, int level, const char *fmt, ...)
48*906Sgm89044 {
49*906Sgm89044 	va_list ap;
50*906Sgm89044 	char	buf[256];
51*906Sgm89044 
52*906Sgm89044 	if (dca_debug & level) {
53*906Sgm89044 		va_start(ap, fmt);
54*906Sgm89044 		if (dca == NULL) {
55*906Sgm89044 			(void) sprintf(buf, "%s\n", fmt);
56*906Sgm89044 		} else {
57*906Sgm89044 			(void) sprintf(buf, "%s/%d: %s\n",
58*906Sgm89044 			    ddi_driver_name(dca->dca_dip),
59*906Sgm89044 			    ddi_get_instance(dca->dca_dip), fmt);
60*906Sgm89044 		}
61*906Sgm89044 		vprintf(buf, ap);
62*906Sgm89044 		va_end(ap);
63*906Sgm89044 	}
64*906Sgm89044 }
65*906Sgm89044 #endif
66*906Sgm89044 
67*906Sgm89044 void
dca_error(dca_t * dca,const char * fmt,...)68*906Sgm89044 dca_error(dca_t *dca, const char *fmt, ...)
69*906Sgm89044 {
70*906Sgm89044 	va_list ap;
71*906Sgm89044 	va_start(ap, fmt);
72*906Sgm89044 	dca_dipverror(dca->dca_dip, fmt, ap);
73*906Sgm89044 	va_end(ap);
74*906Sgm89044 }
75*906Sgm89044 
76*906Sgm89044 void
dca_diperror(dev_info_t * dip,const char * fmt,...)77*906Sgm89044 dca_diperror(dev_info_t *dip, const char *fmt, ...)
78*906Sgm89044 {
79*906Sgm89044 	va_list ap;
80*906Sgm89044 	va_start(ap, fmt);
81*906Sgm89044 	dca_dipverror(dip, fmt, ap);
82*906Sgm89044 	va_end(ap);
83*906Sgm89044 }
84*906Sgm89044 
85*906Sgm89044 void
dca_dipverror(dev_info_t * dip,const char * fmt,va_list ap)86*906Sgm89044 dca_dipverror(dev_info_t *dip, const char *fmt, va_list ap)
87*906Sgm89044 {
88*906Sgm89044 	char	buf[256];
89*906Sgm89044 	(void) sprintf(buf, "%s%d: %s", ddi_driver_name(dip),
90*906Sgm89044 			ddi_get_instance(dip), fmt);
91*906Sgm89044 	vcmn_err(CE_WARN, buf, ap);
92*906Sgm89044 }
93