summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/io/bnx/bnxdbg.c
blob: c703d223c3ebf8c07ffd09c63603da3086478da2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Copyright 2014-2017 Cavium, Inc.
 * The contents of this file are subject to the terms of the Common Development
 * and Distribution License, v.1,  (the "License").
 *
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the License at available
 * at http://opensource.org/licenses/CDDL-1.0
 *
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright (c) 2019, Joyent, Inc.
 */

#include "bnx.h"

#define	BNX_BUF_SIZE 256


void
debug_break(void *ctx)
{
	um_device_t *um = (um_device_t *)ctx;
	cmn_err(CE_PANIC, "-> %s panic <-", (um) ? um->dev_name : "(unknown)");
}


void
debug_msg(void *ctx, unsigned long level, char *file, unsigned long line,
    char *msg, ...)
{
	um_device_t *um = (um_device_t *)ctx;
	char buf[BNX_BUF_SIZE];
	va_list argp;

	*buf = '\0';

	if (um != NULL) {
		(void) snprintf(buf, BNX_BUF_SIZE, "%s %s:%lu ", um->dev_name,
		    file, line);
	} else {
		(void) snprintf(buf, BNX_BUF_SIZE, "%s:%lu ", file, line);
	}

	(void) strlcat(buf, msg, BNX_BUF_SIZE);

	va_start(argp, msg);
	vcmn_err(CE_WARN, buf, argp);
	va_end(argp);
}


void
debug_msgx(void *ctx, unsigned long level, char *msg, ...)
{
	um_device_t *um = (um_device_t *)ctx;
	char buf[BNX_BUF_SIZE];
	va_list argp;

	*buf = '\0';

	if (um != NULL) {
		(void) snprintf(buf, BNX_BUF_SIZE, "%s ", um->dev_name);
	}

	(void) strlcat(buf, msg, BNX_BUF_SIZE);

	va_start(argp, msg);
	vcmn_err(CE_WARN, buf, argp);
	va_end(argp);
}