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 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Copyright 2023 Oxide Computer Company
29  */
30 
31 #ifndef	_FMD_AGENT_H
32 #define	_FMD_AGENT_H
33 
34 #include <inttypes.h>
35 #include <libnvpair.h>
36 #include <umem.h>
37 #include <sys/types.h>
38 #include <sys/processor.h>
39 
40 
41 #ifdef	__cplusplus
42 extern "C" {
43 #endif
44 
45 /*
46  * libfmd_agent Interfaces
47  *
48  * Note: The contents of this file are private to the implementation of the
49  * Solaris system and FMD subsystem and are subject to change at any time
50  * without notice.  Applications and drivers using these interfaces will fail
51  * to run on future releases.  These interfaces should not be used for any
52  * purpose until they are publicly documented for use outside of Sun.
53  */
54 
55 #define	FMD_AGENT_VERSION		1
56 
57 #define	FMD_AGENT_RETIRE_DONE		0	/* synchronous success */
58 #define	FMD_AGENT_RETIRE_ASYNC		1	/* asynchronous complete */
59 #define	FMD_AGENT_RETIRE_FAIL		2	/* failure */
60 
61 typedef struct fmd_agent_hdl fmd_agent_hdl_t;
62 
63 extern fmd_agent_hdl_t *fmd_agent_open(int);
64 extern void fmd_agent_close(fmd_agent_hdl_t *);
65 extern int fmd_agent_errno(fmd_agent_hdl_t *);
66 extern const char *fmd_agent_errmsg(fmd_agent_hdl_t *);
67 extern const char *fmd_agent_strerr(int);
68 
69 extern int fmd_agent_page_retire(fmd_agent_hdl_t *, nvlist_t *);
70 extern int fmd_agent_page_unretire(fmd_agent_hdl_t *, nvlist_t *);
71 extern int fmd_agent_page_isretired(fmd_agent_hdl_t *, nvlist_t *);
72 
73 #ifdef __x86
74 extern int fmd_agent_physcpu_info(fmd_agent_hdl_t *, nvlist_t ***cpusp,
75     uint_t *ncpu);
76 extern int fmd_agent_cpu_retire(fmd_agent_hdl_t *, int, int, int);
77 extern int fmd_agent_cpu_unretire(fmd_agent_hdl_t *, int, int, int);
78 extern int fmd_agent_cpu_isretired(fmd_agent_hdl_t *, int, int, int);
79 #endif /* __x86 */
80 
81 /*
82  * Get cache information for the CPUs in the system. Each CPU has multiple
83  * caches, each of which is an nvlist_t *. There is one of these for each
84  * logical CPU in the system. The returned nvlist structures should be treated
85  * as read only.
86  */
87 typedef struct {
88 	uint_t fmcc_ncaches;
89 	nvlist_t **fmcc_caches;
90 } fmd_agent_cpu_cache_t;
91 
92 typedef struct {
93 	uint_t fmc_ncpus;
94 	fmd_agent_cpu_cache_t *fmc_cpus;
95 } fmd_agent_cpu_cache_list_t;
96 
97 extern int fmd_agent_cache_info(fmd_agent_hdl_t *,
98     fmd_agent_cpu_cache_list_t *);
99 extern void fmd_agent_cache_info_free(fmd_agent_hdl_t *,
100     fmd_agent_cpu_cache_list_t *);
101 
102 #ifdef	__cplusplus
103 }
104 #endif
105 
106 #endif	/* _FMD_AGENT_H */
107