xref: /titanic_52/usr/src/cmd/fm/modules/common/cpumem-retire/cma.h (revision 9512fe850e98fdd448c638ca63fdd92a8a510255)
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 2006 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 
33 #include <sys/types.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define	CMA_RA_SUCCESS	0
40 #define	CMA_RA_FAILURE	1
41 
42 typedef struct cma_page {
43 	struct cma_page *pg_next;	/* List of page retirements for retry */
44 	nvlist_t *pg_fmri;		/* FMRI for this page */
45 	uint64_t pg_addr;		/* Address of this page */
46 	char *pg_uuid;			/* UUID for this page's case */
47 	uint_t pg_nretries;		/* Number of retries so far for page */
48 } cma_page_t;
49 
50 typedef struct cma {
51 	struct timespec cma_cpu_delay;	/* CPU offline retry interval */
52 	uint_t cma_cpu_tries;		/* Number of CPU offline retries */
53 	uint_t cma_cpu_dooffline;	/* Whether to offline CPUs */
54 	uint_t cma_cpu_forcedoffline;	/* Whether to do forced CPU offline */
55 	uint_t cma_cpu_doblacklist;	/* Whether to blacklist CPUs */
56 	cma_page_t *cma_pages;		/* List of page retirements for retry */
57 	hrtime_t cma_page_curdelay;	/* Current retry sleep interval */
58 	hrtime_t cma_page_mindelay;	/* Minimum retry sleep interval */
59 	hrtime_t cma_page_maxdelay;	/* Maximum retry sleep interval */
60 	id_t cma_page_timerid;		/* fmd timer ID for retry sleep */
61 	uint_t cma_page_doretire;	/* Whether to retire pages */
62 	uint_t cma_page_maxretries;	/* Maximum retry on page retires */
63 } cma_t;
64 
65 typedef struct cma_stats {
66 	fmd_stat_t cpu_flts;		/* Successful offlines */
67 	fmd_stat_t cpu_fails;		/* Failed offlines */
68 	fmd_stat_t cpu_blfails;		/* Failed blacklists */
69 	fmd_stat_t cpu_supp;		/* Suppressed offlines */
70 	fmd_stat_t cpu_blsupp;		/* Suppressed blacklists */
71 	fmd_stat_t page_flts;		/* Successful page retires */
72 	fmd_stat_t page_fails;		/* Failed page retires */
73 	fmd_stat_t page_supp;		/* Suppressed retires */
74 	fmd_stat_t page_nonent;		/* Retires for non-present pages */
75 	fmd_stat_t page_retmax;		/* Retires for page reached max */
76 	fmd_stat_t bad_flts;		/* Malformed faults */
77 	fmd_stat_t nop_flts;		/* Inapplicable faults */
78 	fmd_stat_t auto_flts;		/* Auto-close faults */
79 } cma_stats_t;
80 
81 extern cma_stats_t cma_stats;
82 extern cma_t cma;
83 
84 extern int cma_cpu_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *, const char *);
85 
86 extern int cma_page_retire(fmd_hdl_t *, nvlist_t *, nvlist_t *, const char *);
87 extern void cma_page_retry(fmd_hdl_t *);
88 extern void cma_page_fini(fmd_hdl_t *);
89 
90 extern int cma_set_errno(int);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 #endif /* _CMA_H */
97