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 53062Scindi * Common Development and Distribution License (the "License"). 63062Scindi * 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 */ 211193Smws 220Sstevel@tonic-gate /* 2312967Sgavin.maltby@oracle.com * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _FMD_H 270Sstevel@tonic-gate #define _FMD_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <libnvpair.h> 300Sstevel@tonic-gate #include <pthread.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate #ifdef __cplusplus 330Sstevel@tonic-gate extern "C" { 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate #include <fmd_list.h> 370Sstevel@tonic-gate #include <fmd_time.h> 380Sstevel@tonic-gate #include <fmd_api.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate struct fmd_conf; /* see <fmd_conf.h> */ 410Sstevel@tonic-gate struct fmd_dispq; /* see <fmd_dispq.h> */ 420Sstevel@tonic-gate struct fmd_timerq; /* see <fmd_timerq.h> */ 430Sstevel@tonic-gate struct fmd_asru_hash; /* see <fmd_asru.h> */ 440Sstevel@tonic-gate struct fmd_scheme_hash; /* see <fmd_fmri.h> */ 450Sstevel@tonic-gate struct fmd_case_hash; /* see <fmd_case.h> */ 460Sstevel@tonic-gate struct fmd_modhash; /* see <fmd_module.h> */ 470Sstevel@tonic-gate struct fmd_module; /* see <fmd_module.h> */ 480Sstevel@tonic-gate struct fmd_log; /* see <fmd_log.h> */ 491193Smws struct fmd_idspace; /* see <fmd_idspace.h> */ 501414Scindi struct topo_hdl; /* see <fm/libtopo.h> */ 510Sstevel@tonic-gate 520Sstevel@tonic-gate typedef struct fmd_statistics { 530Sstevel@tonic-gate fmd_stat_t ds_log_replayed; /* number of events replayed from log */ 540Sstevel@tonic-gate fmd_stat_t ds_log_partials; /* number of events partially commit */ 550Sstevel@tonic-gate fmd_stat_t ds_err_enospc; /* number of events w/ ENOSPC errlog */ 560Sstevel@tonic-gate fmd_stat_t ds_flt_enospc; /* number of events w/ ENOSPC fltlog */ 570Sstevel@tonic-gate fmd_stat_t ds_oth_enospc; /* number of events w/ ENOSPC others */ 580Sstevel@tonic-gate fmd_stat_t ds_dr_gen; /* dynamic reconfiguration generation */ 593062Scindi fmd_stat_t ds_topo_gen; /* topology snapshot generation */ 603062Scindi fmd_stat_t ds_topo_drgen; /* topology DR generation */ 610Sstevel@tonic-gate } fmd_statistics_t; 620Sstevel@tonic-gate 630Sstevel@tonic-gate typedef struct fmd { 640Sstevel@tonic-gate const char *d_version; /* version string for fmd (see fmd.c) */ 650Sstevel@tonic-gate const char *d_pname; /* basename to use for messages */ 660Sstevel@tonic-gate pid_t d_pid; /* process-ID of current daemon */ 670Sstevel@tonic-gate pthread_key_t d_key; /* key for fmd's thread-specific data */ 680Sstevel@tonic-gate volatile int d_signal; /* signal indicating we should quit */ 690Sstevel@tonic-gate volatile int d_running; /* flag set when fmd_run() succeeds */ 70*13036SStephen.Hanson@Sun.COM volatile int d_loaded; /* flag set when all modules loaded */ 711193Smws volatile int d_booted; /* flag set when fmd_run() completes */ 720Sstevel@tonic-gate 730Sstevel@tonic-gate uint_t d_fmd_debug; /* mask of fmd active debugging modes */ 740Sstevel@tonic-gate uint_t d_fmd_dbout; /* fmd debug output sinks (see below) */ 750Sstevel@tonic-gate uint_t d_hdl_debug; /* bool indicating if hdl debug is on */ 760Sstevel@tonic-gate uint_t d_hdl_dbout; /* hdl debug output sinks (see below) */ 770Sstevel@tonic-gate 780Sstevel@tonic-gate char *volatile d_panicstr; /* pointer to formatted panic message */ 790Sstevel@tonic-gate pthread_t d_panictid; /* tid of thread forcing a panic */ 800Sstevel@tonic-gate uint_t d_panicrefs; /* number of attempts to panic */ 810Sstevel@tonic-gate 821193Smws pthread_mutex_t d_xprt_lock; /* transport suspend lock */ 831193Smws uint_t d_xprt_suspend; /* transport suspend count */ 841193Smws uint_t d_xprt_ttl; /* transport default time-to-live */ 851193Smws struct fmd_idspace *d_xprt_ids; /* transport id hash */ 860Sstevel@tonic-gate 870Sstevel@tonic-gate const fmd_timeops_t *d_clockops; /* system clock ops vector */ 880Sstevel@tonic-gate void *d_clockptr; /* system clock private data */ 890Sstevel@tonic-gate 900Sstevel@tonic-gate pthread_mutex_t d_thr_lock; /* lock for d_thr_list */ 910Sstevel@tonic-gate fmd_list_t d_thr_list; /* list of all fmd_thread_t's */ 920Sstevel@tonic-gate void (*d_thr_trace)(); /* thread trace buffer function */ 930Sstevel@tonic-gate int d_thr_sig; /* cached copy of client.thrsig */ 940Sstevel@tonic-gate 950Sstevel@tonic-gate pthread_mutex_t d_mod_lock; /* lock for d_mod_list */ 960Sstevel@tonic-gate fmd_list_t d_mod_list; /* list of modules in load order */ 970Sstevel@tonic-gate struct fmd_modhash *d_mod_hash; /* hash of modules by base name */ 981193Smws fmd_event_t *d_mod_event; /* boot event for module quiesce */ 990Sstevel@tonic-gate 1000Sstevel@tonic-gate uint_t d_alloc_msecs; /* initial delay time for alloc retry */ 1010Sstevel@tonic-gate uint_t d_alloc_tries; /* max # times to retry an allocation */ 1020Sstevel@tonic-gate uint_t d_str_buckets; /* def # of buckets for string hashes */ 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate const char *d_rootdir; /* root directory path */ 1050Sstevel@tonic-gate const char *d_platform; /* platform name (uname -i) */ 1060Sstevel@tonic-gate const char *d_machine; /* machine class name (uname -m) */ 1070Sstevel@tonic-gate const char *d_isaname; /* processor ISA name (uname -p) */ 1080Sstevel@tonic-gate 1097171Seschrock void *d_sysev_hdl; /* legacy sysevent handle */ 1100Sstevel@tonic-gate nv_alloc_t d_nva; /* libnvpair allocator handle */ 1110Sstevel@tonic-gate nvlist_t *d_auth; /* FMRI authority nvlist */ 1123062Scindi pthread_mutex_t d_topo_lock; /* lock for topo hdl */ 1133062Scindi fmd_list_t d_topo_list; /* list of all topology snapshots */ 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate struct fmd_conf *d_conf; /* global configuration properties */ 1160Sstevel@tonic-gate uint_t d_fg; /* cached value of "fg" property */ 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate fmd_statistics_t *d_stats; /* root module statistics collection */ 1190Sstevel@tonic-gate pthread_mutex_t d_stats_lock; /* root module statistics lock */ 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate struct fmd_module *d_rmod; /* root module for fmd's main thread */ 1220Sstevel@tonic-gate struct fmd_module *d_self; /* self module for fmd's diagnosis */ 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate pthread_mutex_t d_err_lock; /* lock for stderr and error stats */ 1250Sstevel@tonic-gate fmd_stat_t *d_errstats; /* program-wide error statistics */ 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate struct fmd_timerq *d_timers; /* timer queue for module timers */ 1280Sstevel@tonic-gate struct fmd_dispq *d_disp; /* dispatch queue for incoming events */ 1290Sstevel@tonic-gate struct fmd_scheme_hash *d_schemes; /* hash of fmri scheme modules */ 1300Sstevel@tonic-gate struct fmd_asru_hash *d_asrus; /* hash of cached asru objects */ 1310Sstevel@tonic-gate struct fmd_case_hash *d_cases; /* hash of active cases */ 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate pthread_rwlock_t d_log_lock; /* log pointer lock (r=use, w=rotate) */ 1340Sstevel@tonic-gate struct fmd_log *d_errlog; /* log file for error events */ 1350Sstevel@tonic-gate struct fmd_log *d_fltlog; /* log file for fault events */ 13612967Sgavin.maltby@oracle.com 13712967Sgavin.maltby@oracle.com pthread_rwlock_t d_hvilog_lock; /* log pointer lock (r=use, w=rotate) */ 13812967Sgavin.maltby@oracle.com struct fmd_log *d_hvilog; /* log file for hi value info events */ 13912967Sgavin.maltby@oracle.com 14012967Sgavin.maltby@oracle.com pthread_rwlock_t d_ilog_lock; /* log pointer lock (r=use, w=rotate) */ 14112967Sgavin.maltby@oracle.com struct fmd_log *d_ilog; /* log file for info events */ 14212967Sgavin.maltby@oracle.com 1436559Sstephh pthread_cond_t d_fmd_cv; /* sync startup with rpc */ 1446559Sstephh pthread_mutex_t d_fmd_lock; /* sync startup with rpc */ 1450Sstevel@tonic-gate } fmd_t; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* 1480Sstevel@tonic-gate * Exit status values used for the few places within fmd where we exit(2) or 1490Sstevel@tonic-gate * return from main(). fmd only exits if a fatal error occurs during startup; 1500Sstevel@tonic-gate * if anything else happens errors are reported and we just keep trucking. 1510Sstevel@tonic-gate */ 1520Sstevel@tonic-gate #define FMD_EXIT_SUCCESS 0 /* successful execution of daemon */ 1530Sstevel@tonic-gate #define FMD_EXIT_ERROR 1 /* failed to initialize daemon */ 1540Sstevel@tonic-gate #define FMD_EXIT_USAGE 2 /* syntax error on command-line */ 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate /* 1570Sstevel@tonic-gate * Values associated with fmd's client.error property, stored as a uint32_t. 1580Sstevel@tonic-gate * By default, we unload bad clients; other values are for use by developers. 1590Sstevel@tonic-gate */ 1600Sstevel@tonic-gate #define FMD_CERROR_UNLOAD 0 /* unload module on error (default) */ 1610Sstevel@tonic-gate #define FMD_CERROR_STOP 1 /* stop fmd for debugger attach */ 1620Sstevel@tonic-gate #define FMD_CERROR_ABORT 2 /* abort fmd and generate core dump */ 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate /* 1650Sstevel@tonic-gate * Values associated with any *dbout (debug output sink) property, stored as 1660Sstevel@tonic-gate * a uint32_t. Currently we permit syslog output and stderr output. 1670Sstevel@tonic-gate */ 1680Sstevel@tonic-gate #define FMD_DBOUT_SYSLOG 0x1 /* output to syslog(LOG_DEBUG) */ 1690Sstevel@tonic-gate #define FMD_DBOUT_STDERR 0x2 /* output to stderr */ 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate extern const char _fmd_version[]; 1720Sstevel@tonic-gate extern fmd_t fmd; 1730Sstevel@tonic-gate 1741193Smws extern void fmd_door_server(void *); 1750Sstevel@tonic-gate extern void fmd_create(fmd_t *, const char *, const char *, const char *); 1760Sstevel@tonic-gate extern void fmd_destroy(fmd_t *); 1770Sstevel@tonic-gate extern void fmd_run(fmd_t *, int); 1780Sstevel@tonic-gate extern void fmd_help(fmd_t *); 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate #ifdef __cplusplus 1810Sstevel@tonic-gate } 1820Sstevel@tonic-gate #endif 1830Sstevel@tonic-gate 1840Sstevel@tonic-gate #endif /* _FMD_H */ 185