xref: /titanic_41/usr/src/cmd/fm/modules/sun4v/etm/etm_ckpt.h (revision 25351652d920ae27c5a56c199da581033ce763f6)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * etm_ckpt.h
29  *
30  * Header file of checkpointing ereports for persistence
31  *
32  */
33 
34 #ifndef _ETM_CKPT_H
35 #define	_ETM_CKPT_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <fm/fmd_api.h>
42 
43 #define	ETM_CKPT_VERSION	0x10
44 #define	ETM_CKPT_ERPT_PREFIX	"ev"
45 #define	ETM_LINE_LEN		256
46 
47 /*
48  * Format of a named buffer that stores an ereport.
49  */
50 typedef struct etm_ckpt_erpt_buf {
51 	uint8_t		eb_ver;		/* version major.minor */
52 	uint8_t		eb_rev;		/* reserved field */
53 	uint16_t	eb_len;		/* size of packed ereport */
54 					/* nvlist packed erpt event */
55 } etm_ckpt_erpt_buf_t;
56 
57 /*
58  * Ereport id
59  * Each ereport, which is stored in a named buffer, is uniquely identified by
60  * fields in the ereport. The named buffer name is derived from this struct
61  * as following
62  *     ev_${ena}_${hash{class)}_${tod[1]}_${primary}
63  */
64 typedef struct etm_ckpt_erpt_id {
65 	uint64_t	ei_ena;		/* ereport ena */
66 	uint32_t	ei_tod1;	/* tod[1]: fractional second */
67 	uint16_t	ei_hash;	/* hash(ereport class name) */
68 	uint8_t		ei_pri;		/* primary field */
69 	uint8_t		ei_rev;		/* reserved field */
70 } etm_ckpt_erpt_id_t;
71 
72 /*
73  * A circular list of ereport ids
74  */
75 typedef struct etm_ckpt_id_list {
76 	uint8_t		il_ver;		/* version major.minor */
77 	uint8_t		il_rev1;	/* reserve  field */
78 	uint16_t	il_max;		/* max number of erpt ids in list */
79 	uint16_t	il_cnt;		/* number of valid ids in list */
80 	uint16_t	il_head;	/* head of the list */
81 	uint16_t	il_tail;	/* tail of the list */
82 	uint16_t	il_ids_sz;	/* size of the array of ids */
83 	uint32_t	il_rev2;	/* reserve  field */
84 					/* array of ids */
85 } etm_ckpt_id_list_t;
86 
87 #define	ETM_CKPT_IL_BUF		"idlist"
88 #define	ETM_CKPT_IL_MIN_SIZE	0x8
89 
90 /*
91  * Checkpoint options
92  */
93 #define	ETM_CKPT_NOOP		0x0
94 #define	ETM_CKPT_SAVE		0x1
95 #define	ETM_CKPT_RESTORE	0x2
96 
97 void etm_ckpt_recover(fmd_hdl_t *hdl);
98 int etm_ckpt_add(fmd_hdl_t *hdl, nvlist_t *evp);
99 int etm_ckpt_delete(fmd_hdl_t *hdl, nvlist_t *evp);
100 
101 void etm_ckpt_init(fmd_hdl_t *hdl);
102 void etm_ckpt_fini(fmd_hdl_t *hdl);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #endif /* _ETM_CKPT_H */
109