1168404Spjd/*
2168404Spjd * CDDL HEADER START
3168404Spjd *
4168404Spjd * The contents of this file are subject to the terms of the
5168404Spjd * Common Development and Distribution License, Version 1.0 only
6168404Spjd * (the "License").  You may not use this file except in compliance
7168404Spjd * with the License.
8168404Spjd *
9168404Spjd * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10168404Spjd * or http://www.opensolaris.org/os/licensing.
11168404Spjd * See the License for the specific language governing permissions
12168404Spjd * and limitations under the License.
13168404Spjd *
14168404Spjd * When distributing Covered Code, include this CDDL HEADER in each
15168404Spjd * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16168404Spjd * If applicable, add the following below this CDDL HEADER, with the
17168404Spjd * fields enclosed by brackets "[]" replaced with your own identifying
18168404Spjd * information: Portions Copyright [yyyy] [name of copyright owner]
19168404Spjd *
20168404Spjd * CDDL HEADER END
21168404Spjd */
22168404Spjd/*
23168404Spjd * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24168404Spjd * Use is subject to license terms.
25168404Spjd */
26168404Spjd
27168404Spjd#ifndef	_ERRORQ_H
28168404Spjd#define	_ERRORQ_H
29168404Spjd
30168404Spjd#pragma ident	"%Z%%M%	%I%	%E% SMI"
31168404Spjd
32168404Spjd#include <sys/types.h>
33168404Spjd#include <sys/time.h>
34168404Spjd#include <sys/nvpair.h>
35168404Spjd
36168404Spjd#ifdef	__cplusplus
37168404Spjdextern "C" {
38168404Spjd#endif
39168404Spjd
40168404Spjdtypedef struct errorq errorq_t;
41168404Spjdtypedef struct errorq_elem errorq_elem_t;
42168404Spjdtypedef void (*errorq_func_t)(void *, const void *, const errorq_elem_t *);
43168404Spjd
44168404Spjd/*
45168404Spjd * Public flags for errorq_create(): bit range 0-15
46168404Spjd */
47168404Spjd#define	ERRORQ_VITAL	0x0001	/* drain queue automatically on system reset */
48168404Spjd
49168404Spjd/*
50168404Spjd * Public flags for errorq_dispatch():
51168404Spjd */
52168404Spjd#define	ERRORQ_ASYNC	0	/* schedule async queue drain for caller */
53168404Spjd#define	ERRORQ_SYNC	1	/* do not schedule drain; caller will drain */
54168404Spjd
55168404Spjd#ifdef	_KERNEL
56168404Spjd
57168404Spjdextern errorq_t *errorq_create(const char *, errorq_func_t, void *,
58168404Spjd    ulong_t, size_t, uint_t, uint_t);
59168404Spjd
60168404Spjdextern errorq_t *errorq_nvcreate(const char *, errorq_func_t, void *,
61168404Spjd    ulong_t, size_t, uint_t, uint_t);
62168404Spjd
63168404Spjdextern void errorq_destroy(errorq_t *);
64168404Spjdextern void errorq_dispatch(errorq_t *, const void *, size_t, uint_t);
65168404Spjdextern void errorq_drain(errorq_t *);
66168404Spjdextern void errorq_init(void);
67168404Spjdextern void errorq_panic(void);
68168404Spjdextern errorq_elem_t *errorq_reserve(errorq_t *);
69168404Spjdextern void errorq_commit(errorq_t *, errorq_elem_t *, uint_t);
70168404Spjdextern void errorq_cancel(errorq_t *, errorq_elem_t *);
71168404Spjdextern nvlist_t *errorq_elem_nvl(errorq_t *, const errorq_elem_t *);
72168404Spjdextern nv_alloc_t *errorq_elem_nva(errorq_t *, const errorq_elem_t *);
73168404Spjdextern void *errorq_elem_dup(errorq_t *, const errorq_elem_t *,
74168404Spjd    errorq_elem_t **);
75168404Spjdextern void errorq_dump();
76168404Spjd
77168404Spjd#endif	/* _KERNEL */
78168404Spjd
79168404Spjd#ifdef	__cplusplus
80168404Spjd}
81168404Spjd#endif
82168404Spjd
83168404Spjd#endif	/* _ERRORQ_H */
84