xref: /titanic_52/usr/src/cmd/fm/modules/common/cpumem-retire/cma.h (revision d2ec54f7875f7e05edd56195adbeb593c947763f)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <fm/fmd_api.h>
32 #include <sys/types.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define	CMA_RA_SUCCESS	0
39 #define	CMA_RA_FAILURE	1
40 
41 #ifdef opl
42 #define	FM_FMRI_HC_CPUIDS	"hc-xscf-cpuids"
43 #endif
44 
45 typedef struct cma_page {
46 	struct cma_page *pg_next;	/* List of page retirements for retry */
47 	nvlist_t *pg_fmri;		/* FMRI for this page */
48 	uint64_t pg_addr;		/* Address of this page */
49 	char *pg_uuid;			/* UUID for this page's case */
50 	uint_t pg_nretries;		/* Number of retries so far for page */
51 } cma_page_t;
52 
53 #ifdef sun4v
54 typedef struct cma_cpu {
55 	struct cma_cpu *cpu_next;	/* List of cpus */
56 	nvlist_t *cpu_fmri;		/* FMRI for this cpu entry  */
57 	int cpuid;			/* physical id of this cpu */
58 	char *cpu_uuid;			/* UUID for this cpu's case */
59 	uint_t cpu_nretries;		/* Number of retries so far for cpu */
60 } cma_cpu_t;
61 #endif /* sun4v */
62 
63 typedef struct cma {
64 	struct timespec cma_cpu_delay;	/* CPU offline retry interval */
65 	uint_t cma_cpu_tries;		/* Number of CPU offline retries */
66 	uint_t cma_cpu_dooffline;	/* Whether to offline CPUs */
67 	uint_t cma_cpu_forcedoffline;	/* Whether to do forced CPU offline */
68 	uint_t cma_cpu_doonline;	/* Whether to online CPUs */
69 	uint_t cma_cpu_doblacklist;	/* Whether to blacklist CPUs */
70 	uint_t cma_cpu_dounblacklist;	/* Whether to unblacklist CPUs */
71 	cma_page_t *cma_pages;		/* List of page retirements for retry */
72 	hrtime_t cma_page_curdelay;	/* Current retry sleep interval */
73 	hrtime_t cma_page_mindelay;	/* Minimum retry sleep interval */
74 	hrtime_t cma_page_maxdelay;	/* Maximum retry sleep interval */
75 	id_t cma_page_timerid;		/* fmd timer ID for retry sleep */
76 	uint_t cma_page_doretire;	/* Whether to retire pages */
77 	uint_t cma_page_dounretire;	/* Whether to unretire pages */
78 #ifdef sun4v
79 	cma_cpu_t *cma_cpus;		/* List of cpus */
80 	hrtime_t cma_cpu_curdelay;	/* Current retry sleep interval */
81 	hrtime_t cma_cpu_mindelay;	/* Minimum retry sleep interval */
82 	hrtime_t cma_cpu_maxdelay;	/* Maximum retry sleep interval */
83 	id_t cma_cpu_timerid;		/* LDOM cpu timer */
84 #endif /* sun4v */
85 } cma_t;
86 
87 typedef struct cma_stats {
88 	fmd_stat_t cpu_flts;		/* Successful offlines */
89 	fmd_stat_t cpu_repairs;		/* Successful onlines */
90 	fmd_stat_t cpu_fails;		/* Failed offlines/onlines */
91 	fmd_stat_t cpu_blfails;		/* Failed blacklists */
92 	fmd_stat_t cpu_supp;		/* Suppressed offlines/onlines */
93 	fmd_stat_t cpu_blsupp;		/* Suppressed blacklists */
94 	fmd_stat_t page_flts;		/* Successful page retires */
95 	fmd_stat_t page_repairs;	/* Successful page unretires */
96 	fmd_stat_t page_fails;		/* Failed page retires/unretires */
97 	fmd_stat_t page_supp;		/* Suppressed retires/unretires */
98 	fmd_stat_t page_nonent;		/* Retires for non-present pages */
99 	fmd_stat_t bad_flts;		/* Malformed faults */
100 	fmd_stat_t nop_flts;		/* Inapplicable faults */
101 	fmd_stat_t auto_flts;		/* Auto-close faults */
102 } cma_stats_t;
103 
104 extern cma_stats_t cma_stats;
105 extern cma_t cma;
106 
107 extern int cma_cpu_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
108     const char *, boolean_t);
109 #ifdef opl
110 extern int cma_cpu_hc_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *,
111     const char *, boolean_t);
112 #endif
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_page_cmd(fmd_hdl_t *, int, nvlist_t *);
128 
129 #ifdef sun4v
130 extern void cma_cpu_fini(fmd_hdl_t *);
131 extern void cma_cpu_retry(fmd_hdl_t *);
132 #endif /* sun4v */
133 
134 extern const char *p_online_state_fmt(int);
135 
136 #ifdef __cplusplus
137 }
138 #endif
139 
140 #endif /* _CMA_H */
141