xref: /illumos-gate/usr/src/uts/common/io/bnx/bnxdbg.c (revision c26bf377e2245534feb1f92b43f6d4ed32513c41)
1 /*
2  * Copyright 2014-2017 Cavium, Inc.
3  * The contents of this file are subject to the terms of the Common Development
4  * and Distribution License, v.1,  (the "License").
5  *
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the License at available
9  * at http://opensource.org/licenses/CDDL-1.0
10  *
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14 
15 /*
16  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
17  * Copyright (c) 2019, Joyent, Inc.
18  */
19 
20 #include "bnx.h"
21 
22 #define	BNX_BUF_SIZE 256
23 
24 
25 void
26 debug_break(void *ctx)
27 {
28 	um_device_t *um = (um_device_t *)ctx;
29 	cmn_err(CE_PANIC, "-> %s panic <-", (um) ? um->dev_name : "(unknown)");
30 }
31 
32 
33 void
34 debug_msg(void *ctx, unsigned long level, char *file, unsigned long line,
35     char *msg, ...)
36 {
37 	um_device_t *um = (um_device_t *)ctx;
38 	char buf[BNX_BUF_SIZE];
39 	va_list argp;
40 
41 	*buf = '\0';
42 
43 	if (um != NULL) {
44 		(void) snprintf(buf, BNX_BUF_SIZE, "%s %s:%lu ", um->dev_name,
45 		    file, line);
46 	} else {
47 		(void) snprintf(buf, BNX_BUF_SIZE, "%s:%lu ", file, line);
48 	}
49 
50 	(void) strlcat(buf, msg, BNX_BUF_SIZE);
51 
52 	va_start(argp, msg);
53 	vcmn_err(CE_WARN, buf, argp);
54 	va_end(argp);
55 }
56 
57 
58 void
59 debug_msgx(void *ctx, unsigned long level, char *msg, ...)
60 {
61 	um_device_t *um = (um_device_t *)ctx;
62 	char buf[BNX_BUF_SIZE];
63 	va_list argp;
64 
65 	*buf = '\0';
66 
67 	if (um != NULL) {
68 		(void) snprintf(buf, BNX_BUF_SIZE, "%s ", um->dev_name);
69 	}
70 
71 	(void) strlcat(buf, msg, BNX_BUF_SIZE);
72 
73 	va_start(argp, msg);
74 	vcmn_err(CE_WARN, buf, argp);
75 	va_end(argp);
76 }
77