10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*12066SRobert.Johnston@Sun.COM * Common Development and Distribution License (the "License"). 6*12066SRobert.Johnston@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12066SRobert.Johnston@Sun.COM * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _FMD_EVENTQ_H 260Sstevel@tonic-gate #define _FMD_EVENTQ_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <pthread.h> 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate #include <fmd_event.h> 350Sstevel@tonic-gate #include <fmd_list.h> 360Sstevel@tonic-gate 371193Smws typedef struct fmd_eventqstat { 381193Smws fmd_stat_t eqs_dispatched; /* total events dispatched to queue */ 391193Smws fmd_stat_t eqs_dequeued; /* total events dequeued by consumer */ 401193Smws fmd_stat_t eqs_prdequeued; /* total protocol events dequeued */ 411193Smws fmd_stat_t eqs_dropped; /* total events dropped by queue */ 421193Smws fmd_stat_t eqs_wcnt; /* count of events waiting on queue */ 431193Smws fmd_stat_t eqs_wtime; /* total wait time (pre-dispatch) */ 441193Smws fmd_stat_t eqs_wlentime; /* total wait length * time product */ 451193Smws fmd_stat_t eqs_wlastupdate; /* hrtime of last wait queue update */ 461193Smws fmd_stat_t eqs_dtime; /* total dispatch time */ 471193Smws fmd_stat_t eqs_dlastupdate; /* hrtime of last dispatch */ 481193Smws } fmd_eventqstat_t; 491193Smws 500Sstevel@tonic-gate typedef struct fmd_eventqelem { 510Sstevel@tonic-gate fmd_list_t eqe_list; /* linked-list prev/next pointers */ 520Sstevel@tonic-gate fmd_event_t *eqe_event; /* pointer to event */ 530Sstevel@tonic-gate } fmd_eventqelem_t; 540Sstevel@tonic-gate 550Sstevel@tonic-gate struct fmd_module; /* see <fmd_module.h> */ 560Sstevel@tonic-gate 570Sstevel@tonic-gate typedef struct fmd_eventq { 580Sstevel@tonic-gate pthread_mutex_t eq_lock; /* lock protecting queue contents */ 590Sstevel@tonic-gate pthread_cond_t eq_cv; /* condition variable for waiters */ 600Sstevel@tonic-gate fmd_list_t eq_list; /* list head/tail pointers for queue */ 610Sstevel@tonic-gate struct fmd_module *eq_mod; /* module associated with this queue */ 621193Smws pthread_mutex_t *eq_stats_lock; /* lock that protects eq_stats */ 631193Smws fmd_eventqstat_t *eq_stats; /* statistics associated with queue */ 640Sstevel@tonic-gate uint_t eq_limit; /* limit on number of queue elements */ 650Sstevel@tonic-gate uint_t eq_size; /* number of elements on queue */ 661193Smws uint_t eq_flags; /* flags for abort and suspend */ 671193Smws id_t eq_sgid; /* subscription group id for dispq */ 680Sstevel@tonic-gate } fmd_eventq_t; 690Sstevel@tonic-gate 701193Smws #define FMD_EVENTQ_ABORT 0x1 /* return NULL from fmd_eventq_delete */ 711193Smws #define FMD_EVENTQ_SUSPEND 0x2 /* suspend in fmd_eventq_delete */ 721193Smws 731193Smws extern fmd_eventq_t *fmd_eventq_create(struct fmd_module *, 741193Smws fmd_eventqstat_t *, pthread_mutex_t *, uint_t); 750Sstevel@tonic-gate extern void fmd_eventq_destroy(fmd_eventq_t *); 760Sstevel@tonic-gate extern void fmd_eventq_insert_at_head(fmd_eventq_t *, fmd_event_t *); 770Sstevel@tonic-gate extern void fmd_eventq_insert_at_time(fmd_eventq_t *, fmd_event_t *); 780Sstevel@tonic-gate extern fmd_event_t *fmd_eventq_delete(fmd_eventq_t *); 791193Smws extern void fmd_eventq_done(fmd_eventq_t *); 800Sstevel@tonic-gate extern void fmd_eventq_cancel(fmd_eventq_t *, uint_t, void *); 811193Smws extern void fmd_eventq_suspend(fmd_eventq_t *); 821193Smws extern void fmd_eventq_resume(fmd_eventq_t *); 830Sstevel@tonic-gate extern void fmd_eventq_abort(fmd_eventq_t *); 84*12066SRobert.Johnston@Sun.COM extern void fmd_eventq_drop_topo(fmd_eventq_t *); 850Sstevel@tonic-gate 860Sstevel@tonic-gate #ifdef __cplusplus 870Sstevel@tonic-gate } 880Sstevel@tonic-gate #endif 890Sstevel@tonic-gate 900Sstevel@tonic-gate #endif /* _FMD_EVENTQ_H */ 91