xref: /illumos-gate/usr/src/cmd/fm/modules/common/cpumem-retire/cma.h (revision fe54a78e1aacf39261ad56e9903bce02e3fb6d21)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _CMA_H
27 #define	_CMA_H
28 
29 #include <fm/fmd_api.h>
30 #include <sys/types.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #define	CMA_RA_SUCCESS	0
37 #define	CMA_RA_FAILURE	1
38 
39 #ifdef opl
40 #define	FM_FMRI_HC_CPUIDS	"hc-xscf-cpuids"
41 #endif
42 
43 #ifdef i386
44 extern boolean_t cma_is_native;
45 #endif
46 
47 typedef struct cma_page {
48 	struct cma_page *pg_next;	/* List of page retirements for retry */
49 	nvlist_t *pg_fmri;		/* FMRI for this page */
50 	uint64_t pg_addr;		/* Address of this page */
51 	char *pg_uuid;			/* UUID for this page's case */
52 	uint_t pg_nretries;		/* Number of retries so far for page */
53 } cma_page_t;
54 
55 #ifdef sun4v
56 typedef struct cma_cpu {
57 	struct cma_cpu *cpu_next;	/* List of cpus */
58 	nvlist_t *cpu_fmri;		/* FMRI for this cpu entry  */
59 	int cpuid;			/* physical id of this cpu */
60 	char *cpu_uuid;			/* UUID for this cpu's case */
61 	uint_t cpu_nretries;		/* Number of retries so far for cpu */
62 } cma_cpu_t;
63 #endif /* sun4v */
64 
65 typedef struct cma {
66 	struct timespec cma_cpu_delay;	/* CPU offline retry interval */
67 	uint_t cma_cpu_tries;		/* Number of CPU offline retries */
68 	uint_t cma_cpu_dooffline;	/* Whether to offline CPUs */
69 	uint_t cma_cpu_forcedoffline;	/* Whether to do forced CPU offline */
70 	uint_t cma_cpu_doonline;	/* Whether to online CPUs */
71 	uint_t cma_cpu_doblacklist;	/* Whether to blacklist CPUs */
72 	uint_t cma_cpu_dounblacklist;	/* Whether to unblacklist CPUs */
73 	cma_page_t *cma_pages;		/* List of page retirements for retry */
74 	hrtime_t cma_page_curdelay;	/* Current retry sleep interval */
75 	hrtime_t cma_page_mindelay;	/* Minimum retry sleep interval */
76 	hrtime_t cma_page_maxdelay;	/* Maximum retry sleep interval */
77 	id_t cma_page_timerid;		/* fmd timer ID for retry sleep */
78 	uint_t cma_page_doretire;	/* Whether to retire pages */
79 	uint_t cma_page_dounretire;	/* Whether to unretire pages */
80 #ifdef sun4v
81 	cma_cpu_t *cma_cpus;		/* List of cpus */
82 	hrtime_t cma_cpu_curdelay;	/* Current retry sleep interval */
83 	hrtime_t cma_cpu_mindelay;	/* Minimum retry sleep interval */
84 	hrtime_t cma_cpu_maxdelay;	/* Maximum retry sleep interval */
85 	id_t cma_cpu_timerid;		/* LDOM cpu timer */
86 #endif /* sun4v */
87 } cma_t;
88 
89 typedef struct cma_stats {
90 	fmd_stat_t cpu_flts;		/* Successful offlines */
91 	fmd_stat_t cpu_repairs;		/* Successful onlines */
92 	fmd_stat_t cpu_fails;		/* Failed offlines/onlines */
93 	fmd_stat_t cpu_blfails;		/* Failed blacklists */
94 	fmd_stat_t cpu_supp;		/* Suppressed offlines/onlines */
95 	fmd_stat_t cpu_blsupp;		/* Suppressed blacklists */
96 	fmd_stat_t page_flts;		/* Successful page retires */
97 	fmd_stat_t page_repairs;	/* Successful page unretires */
98 	fmd_stat_t page_fails;		/* Failed page retires/unretires */
99 	fmd_stat_t page_supp;		/* Suppressed retires/unretires */
100 	fmd_stat_t page_nonent;		/* Retires for non-present pages */
101 	fmd_stat_t bad_flts;		/* Malformed faults */
102 	fmd_stat_t nop_flts;		/* Inapplicable faults */
103 	fmd_stat_t auto_flts;		/* Auto-close faults */
104 } cma_stats_t;
105 
106 extern cma_stats_t cma_stats;
107 extern cma_t cma;
108 
109 extern int cma_cpu_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
110     const char *, boolean_t);
111 extern int cma_cpu_hc_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
112     const char *, boolean_t);
113 extern int cma_page_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
114     const char *, boolean_t);
115 extern void cma_page_retry(fmd_hdl_t *);
116 extern void cma_page_fini(fmd_hdl_t *);
117 extern int cma_set_errno(int);
118 
119 extern int cma_cache_way_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
120     const char *, boolean_t);
121 /*
122  * Platforms may have their own implementations of these functions
123  */
124 extern int cma_cpu_blacklist(fmd_hdl_t *, nvlist_t *, nvlist_t *, boolean_t);
125 extern int cma_cpu_statechange(fmd_hdl_t *, nvlist_t *, const char *, int,
126     boolean_t);
127 extern int cma_fmri_page_service_state(fmd_hdl_t *, nvlist_t *);
128 extern int cma_fmri_page_retire(fmd_hdl_t *, nvlist_t *);
129 extern int cma_fmri_page_unretire(fmd_hdl_t *, nvlist_t *);
130 
131 #ifdef sun4v
132 extern void cma_cpu_fini(fmd_hdl_t *);
133 extern void cma_cpu_retry(fmd_hdl_t *);
134 #endif /* sun4v */
135 
136 extern const char *p_online_state_fmt(int);
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* _CMA_H */
143