xref: /titanic_52/usr/src/cmd/fm/modules/common/cpumem-retire/cma.h (revision 55f5292c612446ce6f93ddd248c0019b5974618b)
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_rsrc;		/* Resource for this page */
50 	nvlist_t *pg_asru;		/* ASRU for this page */
51 	uint64_t pg_addr;		/* Address of this page */
52 	char *pg_uuid;			/* UUID for this page's case */
53 	uint_t pg_nretries;		/* Number of retries so far for page */
54 } cma_page_t;
55 
56 #ifdef sun4v
57 typedef struct cma_cpu {
58 	struct cma_cpu *cpu_next;	/* List of cpus */
59 	nvlist_t *cpu_fmri;		/* FMRI for this cpu entry  */
60 	int cpuid;			/* physical id of this cpu */
61 	char *cpu_uuid;			/* UUID for this cpu's case */
62 	uint_t cpu_nretries;		/* Number of retries so far for cpu */
63 } cma_cpu_t;
64 #endif /* sun4v */
65 
66 typedef struct cma {
67 	struct timespec cma_cpu_delay;	/* CPU offline retry interval */
68 	uint_t cma_cpu_tries;		/* Number of CPU offline retries */
69 	uint_t cma_cpu_dooffline;	/* Whether to offline CPUs */
70 	uint_t cma_cpu_forcedoffline;	/* Whether to do forced CPU offline */
71 	uint_t cma_cpu_doonline;	/* Whether to online CPUs */
72 	uint_t cma_cpu_doblacklist;	/* Whether to blacklist CPUs */
73 	uint_t cma_cpu_dounblacklist;	/* Whether to unblacklist CPUs */
74 	cma_page_t *cma_pages;		/* List of page retirements for retry */
75 	hrtime_t cma_page_curdelay;	/* Current retry sleep interval */
76 	hrtime_t cma_page_mindelay;	/* Minimum retry sleep interval */
77 	hrtime_t cma_page_maxdelay;	/* Maximum retry sleep interval */
78 	id_t cma_page_timerid;		/* fmd timer ID for retry sleep */
79 	uint_t cma_page_doretire;	/* Whether to retire pages */
80 	uint_t cma_page_dounretire;	/* Whether to unretire pages */
81 #ifdef sun4v
82 	cma_cpu_t *cma_cpus;		/* List of cpus */
83 	hrtime_t cma_cpu_curdelay;	/* Current retry sleep interval */
84 	hrtime_t cma_cpu_mindelay;	/* Minimum retry sleep interval */
85 	hrtime_t cma_cpu_maxdelay;	/* Maximum retry sleep interval */
86 	id_t cma_cpu_timerid;		/* LDOM cpu timer */
87 #endif /* sun4v */
88 } cma_t;
89 
90 typedef struct cma_stats {
91 	fmd_stat_t cpu_flts;		/* Successful offlines */
92 	fmd_stat_t cpu_repairs;		/* Successful onlines */
93 	fmd_stat_t cpu_fails;		/* Failed offlines/onlines */
94 	fmd_stat_t cpu_blfails;		/* Failed blacklists */
95 	fmd_stat_t cpu_supp;		/* Suppressed offlines/onlines */
96 	fmd_stat_t cpu_blsupp;		/* Suppressed blacklists */
97 	fmd_stat_t page_flts;		/* Successful page retires */
98 	fmd_stat_t page_repairs;	/* Successful page unretires */
99 	fmd_stat_t page_fails;		/* Failed page retires/unretires */
100 	fmd_stat_t page_supp;		/* Suppressed retires/unretires */
101 	fmd_stat_t page_nonent;		/* Retires for non-present pages */
102 	fmd_stat_t bad_flts;		/* Malformed faults */
103 	fmd_stat_t nop_flts;		/* Inapplicable faults */
104 	fmd_stat_t auto_flts;		/* Auto-close faults */
105 } cma_stats_t;
106 
107 extern cma_stats_t cma_stats;
108 extern cma_t cma;
109 
110 extern int cma_cpu_cpu_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
111     const char *, boolean_t);
112 extern int cma_cpu_hc_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
113     const char *, boolean_t);
114 extern int cma_page_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
115     const char *, boolean_t);
116 extern void cma_page_retry(fmd_hdl_t *);
117 extern void cma_page_fini(fmd_hdl_t *);
118 extern int cma_set_errno(int);
119 
120 extern int cma_cache_way_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
121     const char *, boolean_t);
122 /*
123  * Platforms may have their own implementations of these functions
124  */
125 extern int cma_cpu_blacklist(fmd_hdl_t *, nvlist_t *, nvlist_t *, boolean_t);
126 extern int cma_cpu_statechange(fmd_hdl_t *, nvlist_t *, const char *, int,
127     boolean_t);
128 extern int cma_fmri_page_service_state(fmd_hdl_t *, nvlist_t *);
129 extern int cma_fmri_page_retire(fmd_hdl_t *, nvlist_t *);
130 extern int cma_fmri_page_unretire(fmd_hdl_t *, nvlist_t *);
131 
132 #ifdef sun4v
133 extern void cma_cpu_start_retry(fmd_hdl_t *, nvlist_t *, const char *,
134     boolean_t);
135 extern void cma_cpu_fini(fmd_hdl_t *);
136 extern void cma_cpu_retry(fmd_hdl_t *);
137 #endif /* sun4v */
138 
139 extern const char *p_online_state_fmt(int);
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif /* _CMA_H */
146