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