xref: /titanic_51/usr/src/cmd/fm/modules/sun4v/cpumem-retire/cma_page_sun4v.c (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
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 #include <sys/fm/ldom.h>
27 #include <errno.h>
28 #include <fm/fmd_api.h>
29 #include <fm/fmd_agent.h>
30 #include <fm/fmd_fmri.h>
31 
32 extern ldom_hdl_t *cma_lhp;
33 
34 /* ARGSUSED */
35 int
36 cma_fmri_page_service_state(fmd_hdl_t *hdl, nvlist_t *nvl)
37 {
38 	errno = ldom_fmri_status(cma_lhp, nvl);
39 
40 	if (errno == 0 || errno == EINVAL)
41 		return (FMD_SERVICE_STATE_UNUSABLE);
42 	if (errno == EAGAIN)
43 		return (FMD_SERVICE_STATE_ISOLATE_PENDING);
44 
45 	return (FMD_SERVICE_STATE_OK);
46 }
47 
48 /* ARGSUSED */
49 int
50 cma_fmri_page_retire(fmd_hdl_t *hdl, nvlist_t *nvl)
51 {
52 	errno = ldom_fmri_retire(cma_lhp, nvl);
53 
54 	if (errno == 0 || errno == EIO || errno == EINVAL)
55 		return (FMD_AGENT_RETIRE_DONE);
56 	if (errno == EAGAIN)
57 		return (FMD_AGENT_RETIRE_ASYNC);
58 
59 	return (FMD_AGENT_RETIRE_FAIL);
60 }
61 
62 /* ARGSUSED */
63 int
64 cma_fmri_page_unretire(fmd_hdl_t *hdl, nvlist_t *nvl)
65 {
66 	errno = ldom_fmri_unretire(cma_lhp, nvl);
67 
68 	if (errno == 0 || errno == EIO)
69 		return (FMD_AGENT_RETIRE_DONE);
70 
71 	return (FMD_AGENT_RETIRE_FAIL);
72 }
73