xref: /illumos-gate/usr/src/cmd/fm/modules/common/sw-diag-response/common/sw_impl.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 
26 #ifndef	_SW_IMPL_H
27 #define	_SW_IMPL_H
28 
29 #include "sw.h"
30 
31 /*
32  * The common code between software-response and software-diagnosis
33  * needs somewhere to track the subsidaries that have "registered",
34  * their dispatch tables etc.  In the _fmd_init of each module we
35  * call the shared sw_fmd_init code, and there we allocate a
36  * struct sw_modspecific and assign this as the fmd fodule-specific
37  * data with fmd_hdl_setspecific.
38  */
39 struct sw_modspecific {
40 	int swms_dispcnt;
41 	const struct sw_subinfo *(*swms_subinfo)[SW_SUB_MAX];
42 	const struct sw_disp *(*swms_disptbl)[SW_SUB_MAX];
43 	pthread_mutex_t swms_timerlock;
44 	struct {
45 		int swt_state;		/* slot in use? */
46 		id_t swt_timerid;	/* fmd_timer_install result */
47 		id_t swt_ownerid;	/* subsidiary owner id */
48 	} swms_timers[SW_TIMER_MAX];
49 };
50 
51 #define	SW_TMR_INUSE		1
52 #define	SW_TMR_RMVD		0
53 #define	SW_TMR_UNTOUCHED	-1
54 
55 extern swsub_case_close_func_t *sw_sub_case_close_func(fmd_hdl_t *,
56     enum sw_casetype);
57 extern sw_case_vrfy_func_t *sw_sub_case_vrfy_func(fmd_hdl_t *,
58     enum sw_casetype);
59 
60 /*
61  * Software DE fmdo_close entry point.
62  */
63 extern void swde_close(fmd_hdl_t *, fmd_case_t *);
64 
65 /*
66  * Shared functions for software-diagnosis and software-response fmd
67  * module implementation using shared code.  Subsidiaries do not need
68  * to call these functions.
69  *
70  * sw_fmd_init is called from _fmd_init of the two modules, to do most of
71  * the real work of initializing the subsidiaries etc.
72  *
73  * sw_fmd_fini is called from _fmd_fini and calls the swsub_fini
74  * function of each subsidiary after uninstalling all timers.
75  *
76  * sw_recv is the fmdo_recv entry point; it checks the event against
77  * the dispatch table of each subsidiary and dispatches the first
78  * match for each module.
79  *
80  * sw_timeout is the fmdo_timeout entry point; it looks up the unique id_t
81  * of the subsidiary that installed the timer (via sw_timer_install in which
82  * the id is quoted) and calls the swsub_timeout function for that subsidiary.
83  *
84  * swde_case_init and swde_case_fini initialize and finalize the
85  * software-diagnosis case-tracking infrastructure;  swde_case_init
86  * is responsible for unserializing case state.
87  *
88  * sw_id_to_casetype take a subsidiary id and returns the case type it
89  * registered with.
90  */
91 extern int sw_fmd_init(fmd_hdl_t *, const fmd_hdl_info_t *,
92     const struct sw_subinfo *(*)[SW_SUB_MAX]);
93 extern void sw_fmd_fini(fmd_hdl_t *);
94 extern void sw_recv(fmd_hdl_t *, fmd_event_t *, nvlist_t *, const char *);
95 extern void sw_timeout(fmd_hdl_t *, id_t, void *);
96 extern void swde_case_init(fmd_hdl_t *);
97 extern void swde_case_fini(fmd_hdl_t *);
98 
99 enum sw_casetype sw_id_to_casetype(fmd_hdl_t *, id_t);
100 
101 #endif	/* _SW_IMPL_H */
102