xref: /titanic_51/usr/src/uts/common/sys/errorq_impl.h (revision 267b64d58a6a4b7a69129176bbf72eb5e4acf75c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*267b64d5SStephen Hanson  * Common Development and Distribution License (the "License").
6*267b64d5SStephen Hanson  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*267b64d5SStephen Hanson  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_ERRORQ_IMPL_H
277c478bd9Sstevel@tonic-gate #define	_ERRORQ_IMPL_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <sys/errorq.h>
307c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
317c478bd9Sstevel@tonic-gate #include <sys/kstat.h>
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate typedef struct errorq_nvelem {
387c478bd9Sstevel@tonic-gate 	void *eqn_buf;			/* data buf for this nv element */
397c478bd9Sstevel@tonic-gate 	nvlist_t *eqn_nvl;		/* nvlist */
407c478bd9Sstevel@tonic-gate 	nv_alloc_t *eqn_nva;		/* fixed nv allocator */
417c478bd9Sstevel@tonic-gate } errorq_nvelem_t;
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate struct errorq_elem {
447c478bd9Sstevel@tonic-gate 	struct errorq_elem *eqe_next;		/* next on processing list */
457c478bd9Sstevel@tonic-gate 	struct errorq_elem *eqe_prev;		/* prev on free or pend list */
467c478bd9Sstevel@tonic-gate 	struct errorq_elem *eqe_dump;		/* next on crash dump list */
477c478bd9Sstevel@tonic-gate 	void *eqe_data;				/* data for this element */
487c478bd9Sstevel@tonic-gate };
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate typedef struct errorq_kstat {
517c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_dispatched;		/* total errors dispatched */
527c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_dropped;		/* total errors dropped */
537c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_logged;		/* total errors logged */
547c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_reserved;		/* total errors reserved */
557c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_reserve_fail;		/* total reservation failures */
567c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_committed;		/* total errors committed */
577c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_commit_fail;		/* total commit failures */
587c478bd9Sstevel@tonic-gate 	kstat_named_t eqk_cancelled;		/* total reserves cancelled */
597c478bd9Sstevel@tonic-gate } errorq_kstat_t;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate /*
627c478bd9Sstevel@tonic-gate  * errorq implementation flags: bit range 16-31
637c478bd9Sstevel@tonic-gate  */
647c478bd9Sstevel@tonic-gate #define	ERRORQ_ACTIVE	0x00010000		/* queue is enabled */
657c478bd9Sstevel@tonic-gate #define	ERRORQ_NVLIST	0x00020000		/* nvlist queue */
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #define	ERRORQ_NAMELEN	31			/* length of queue name */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate struct errorq {
707c478bd9Sstevel@tonic-gate 	char eq_name[ERRORQ_NAMELEN + 1];	/* string name for debugging */
717c478bd9Sstevel@tonic-gate 	errorq_kstat_t eq_kstat;		/* kstat data (see above) */
727c478bd9Sstevel@tonic-gate 	kstat_t *eq_ksp;			/* pointer to installed kstat */
737c478bd9Sstevel@tonic-gate 	errorq_func_t eq_func;			/* drain callback */
747c478bd9Sstevel@tonic-gate 	void *eq_private;			/* drain callback data */
757c478bd9Sstevel@tonic-gate 	void *eq_data;				/* buffer of queue data */
767c478bd9Sstevel@tonic-gate 	ulong_t eq_qlen;			/* maximum queue length */
777c478bd9Sstevel@tonic-gate 	size_t eq_size;				/* size of element data */
787c478bd9Sstevel@tonic-gate 	uint_t eq_ipl;				/* soft interrupt priority */
797c478bd9Sstevel@tonic-gate 	uint_t eq_flags;			/* flags (see above) */
807c478bd9Sstevel@tonic-gate 	ddi_softintr_t eq_id;			/* soft interrupt identifier */
817c478bd9Sstevel@tonic-gate 	kmutex_t eq_lock;			/* consumer lock */
827c478bd9Sstevel@tonic-gate 	errorq_elem_t *eq_elems;		/* array of all elements */
837c478bd9Sstevel@tonic-gate 	errorq_elem_t *eq_phead;		/* head of processing list */
847c478bd9Sstevel@tonic-gate 	errorq_elem_t *eq_ptail;		/* tail of processing list */
857c478bd9Sstevel@tonic-gate 	errorq_elem_t *eq_pend;			/* list of pending errors */
86*267b64d5SStephen Hanson 	ulong_t *eq_bitmap;			/* bitmap of free elements */
877c478bd9Sstevel@tonic-gate 	errorq_elem_t *eq_dump;			/* list of crash dump elem's */
887c478bd9Sstevel@tonic-gate 	struct errorq *eq_next;			/* next errorq on global list */
89*267b64d5SStephen Hanson 	index_t eq_rotor;			/* best efforts bitmap rotor */
907c478bd9Sstevel@tonic-gate };
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
937c478bd9Sstevel@tonic-gate }
947c478bd9Sstevel@tonic-gate #endif
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #endif	/* _ERRORQ_IMPL_H */
97