xref: /illumos-gate/usr/src/uts/common/sys/devfm.h (revision 4702be99a7621a425e53a63af8ae0ff7fe973b31)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  * Copyright (c) 2018, Joyent, Inc.
25  * Copyright 2023 Oxide Computer Company
26  */
27 
28 #ifndef	_SYS_DEVFM_H
29 #define	_SYS_DEVFM_H
30 
31 #include <sys/types.h>
32 #include <sys/nvpair.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #define	FM_IOC_MAXBUFSZ		32768	/* 32 KiB */
39 #define	FM_IOC_OUT_BUFSZ	32768	/* 32 KiB */
40 #define	FM_IOC_OUT_MAXBUFSZ	1048576	/* 1 MiB */
41 #define	FM_DRV_VERSION		1
42 
43 #define	FM_VERSIONS_VERSION	"fm-versions-version"
44 #define	FM_PAGE_OP_VERSION	"page-operation-version"
45 #define	FM_CPU_OP_VERSION	"cpu-operation-version"
46 #define	FM_CPU_INFO_VERSION	"cpu-info-version"
47 #define	FM_TOPO_LEGACY_VERSION	"topo-legacy-version"
48 #define	FM_CACHE_INFO_VERSION	"cache-info-version"
49 
50 /*
51  * FMA driver ioctl interfaces
52  */
53 #define	FM_IOC			(0xFA << 16)
54 #define	FM_IOC_VERSIONS		(FM_IOC | 1)
55 #define	FM_IOC_PAGE_RETIRE	(FM_IOC | 2)
56 #define	FM_IOC_PAGE_STATUS	(FM_IOC | 3)
57 #define	FM_IOC_PAGE_UNRETIRE	(FM_IOC | 4)
58 
59 #if defined(__x86)
60 #define	FM_IOC_PHYSCPU_INFO	(FM_IOC | 5)
61 #define	FM_IOC_CPU_RETIRE	(FM_IOC | 6)
62 #define	FM_IOC_CPU_STATUS	(FM_IOC | 7)
63 #define	FM_IOC_CPU_UNRETIRE	(FM_IOC | 8)
64 #define	FM_IOC_GENTOPO_LEGACY	(FM_IOC | 9)
65 #endif	/* __x86 */
66 
67 /*
68  * Information about caches. Each CPU that is in the physical CPU information
69  * will be in here in the same ID order allowing one to map them directly.
70  */
71 #define	FM_IOC_CACHE_INFO	(FM_IOC | 10)
72 
73 /*
74  * Types
75  */
76 typedef struct fm_ioc_data {
77 	uint32_t	fid_version;	/* interface version */
78 	size_t		fid_insz;	/* size of packed input nvlist */
79 	caddr_t		fid_inbuf;	/* buf containing packed input nvl */
80 	size_t		fid_outsz;	/* size of packed output nvlist */
81 	caddr_t		fid_outbuf;	/* buf containing packed output nvl */
82 } fm_ioc_data_t;
83 
84 #ifdef _KERNEL
85 typedef struct fm_ioc_data32 {
86 	uint32_t	fid_version;	/* interface version */
87 	size32_t	fid_insz;	/* size of packed input nvlist */
88 	caddr32_t	fid_inbuf;	/* buf containing packed input nvl */
89 	size32_t	fid_outsz;	/* size of packed output nvlist */
90 	caddr32_t	fid_outbuf;	/* buf containing packed output nvl */
91 } fm_ioc_data32_t;
92 #endif	/* _KERNEL */
93 
94 /*
95  * Constants
96  */
97 #define	FM_PAGE_RETIRE_FMRI		"fmri"
98 #define	FM_PHYSCPU_INFO_CPUS		"cpus"
99 #define	FM_CPU_RETIRE_CHIP_ID		"chip_id"
100 #define	FM_PHYSCPU_INFO_NPROCNODES	"procnodes_per_pkg"
101 #define	FM_PHYSCPU_INFO_PROCNODE_ID	"procnodeid"
102 #define	FM_CPU_RETIRE_CORE_ID		"core_id"
103 #define	FM_CPU_RETIRE_STRAND_ID		"strand_id"
104 #define	FM_CPU_RETIRE_OLDSTATUS		"oldstatus"
105 #define	FM_GENTOPO_LEGACY		"gentopolegacy"
106 #define	FM_CACHE_INFO_NCPUS		"ncpus"
107 
108 /*
109  * Properties set by FM_PHYSCPU_INFO
110  */
111 #define	FM_PHYSCPU_INFO_VENDOR_ID	"vendor_id"
112 #define	FM_PHYSCPU_INFO_FAMILY		"family"
113 #define	FM_PHYSCPU_INFO_MODEL		"model"
114 #define	FM_PHYSCPU_INFO_STEPPING	"stepping"
115 
116 /*
117  * When Multi-Chip-Module(MCM) support is added
118  * chip_id should map to the processor package
119  * and not the die in the processor package.
120  * This is for FMA; kernel's perception of
121  * chip_id could differ for MCM.
122  */
123 #define	FM_PHYSCPU_INFO_CHIP_ID		"chip_id"
124 
125 #define	FM_PHYSCPU_INFO_CORE_ID		"core_id"
126 #define	FM_PHYSCPU_INFO_STRAND_ID	"strand_id"
127 #define	FM_PHYSCPU_INFO_STRAND_APICID	"strand_initial_apicid"
128 #define	FM_PHYSCPU_INFO_SMBIOS_ID	"smbios_id"
129 #define	FM_PHYSCPU_INFO_CHIP_ROOTS	"chip_roots"
130 #define	FM_PHYSCPU_INFO_CHIP_REV	"chip_rev"
131 #define	FM_PHYSCPU_INFO_SOCKET_TYPE	"socket_type"
132 #define	FM_PHYSCPU_INFO_CPU_ID		"cpuid"
133 #define	FM_PHYSCPU_INFO_CHIP_IDENTSTR	"chip_identstr"
134 
135 /*
136  * Information exposed by the cache information structure. This is currently
137  * organized by the given caches available to a CPU. There is a given nvlist_t
138  * array for each cache level. The majority of these entries are meant to be
139  * generic across all platforms and derived from the underlying architecture's
140  * metadata (CPUID, CLIDR_EL1, etc.).
141  *
142  * The FM_CACHE_INFO_ID value is manufactured by the kernel. CPU architectures
143  * generally present cache information as specific to a logical CPU. This allows
144  * systems to determine what level caches are shared between different CPUs by
145  * comparing these entries across CPUs. Items prefixed with a given architecture
146  * are specific to it and will not show up on other platforms. These exist so
147  * topology modules can have more information than just the cache-id. While it's
148  * helpful, it doesn't tell us what level of the CPU (or whether it's internal
149  * or external) it exists at. This is going to be architecture and potentially
150  * platform specific given that ARMv8-A/ARMv9-A doesn't define a way to get this
151  * for example.
152  *
153  * It is expected that callers will always fill out the sets and ways
154  * appropriately. If a cache is fully-associative, we expects the number of sets
155  * to be populated and set to 1 that way consumers can attempt to have a uniform
156  * experience here.
157  */
158 #define	FM_CACHE_INFO_LEVEL		"cache-level"	/* uint32_t */
159 #define	FM_CACHE_INFO_TYPE		"cache-type"	/* uint32_t */
160 typedef enum {
161 	FM_CACHE_INFO_T_DATA	= 1 << 0,
162 	FM_CACHE_INFO_T_INSTR	= 1 << 1,
163 	FM_CACHE_INFO_T_UNIFIED	= 1 << 2
164 } fm_cache_info_type_t;
165 #define	FM_CACHE_INFO_NSETS		"cache-sets"	/* uint64_t */
166 #define	FM_CACHE_INFO_NWAYS		"cache-ways"	/* uint32_t */
167 #define	FM_CACHE_INFO_LINE_SIZE		"line-size"	/* uint32_t */
168 #define	FM_CACHE_INFO_TOTAL_SIZE	"total-size"	/* uint64_t */
169 #define	FM_CACHE_INFO_FULLY_ASSOC	"fully-associative" /* boolean (key) */
170 #define	FM_CACHE_INFO_ID		"cache-id"	/* uint64_t */
171 #define	FM_CACHE_INFO_X86_APIC_SHIFT	"x86-apic-shift"	/* uint32_t */
172 
173 #ifdef	__cplusplus
174 }
175 #endif
176 
177 #endif	/* _SYS_DEVFM_H */
178