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 #define FM_CPU_PCI_VERSION "cpu-pci-version" 50 51 /* 52 * FMA driver ioctl interfaces 53 */ 54 #define FM_IOC (0xFA << 16) 55 #define FM_IOC_VERSIONS (FM_IOC | 1) 56 #define FM_IOC_PAGE_RETIRE (FM_IOC | 2) 57 #define FM_IOC_PAGE_STATUS (FM_IOC | 3) 58 #define FM_IOC_PAGE_UNRETIRE (FM_IOC | 4) 59 60 #if defined(__x86) 61 #define FM_IOC_PHYSCPU_INFO (FM_IOC | 5) 62 #define FM_IOC_CPU_RETIRE (FM_IOC | 6) 63 #define FM_IOC_CPU_STATUS (FM_IOC | 7) 64 #define FM_IOC_CPU_UNRETIRE (FM_IOC | 8) 65 #define FM_IOC_GENTOPO_LEGACY (FM_IOC | 9) 66 67 /* 68 * Information about the PCI configuration of physical CPUs. These data contain 69 * chip IDs which correspond to those in the physical CPU information. 70 */ 71 #define FM_IOC_PCI_DATA (FM_IOC | 11) 72 73 #endif /* __x86 */ 74 75 /* 76 * Information about caches. Each CPU that is in the physical CPU information 77 * will be in here in the same ID order allowing one to map them directly. 78 */ 79 #define FM_IOC_CACHE_INFO (FM_IOC | 10) 80 81 /* 82 * Types 83 */ 84 typedef struct fm_ioc_data { 85 uint32_t fid_version; /* interface version */ 86 size_t fid_insz; /* size of packed input nvlist */ 87 caddr_t fid_inbuf; /* buf containing packed input nvl */ 88 size_t fid_outsz; /* size of packed output nvlist */ 89 caddr_t fid_outbuf; /* buf containing packed output nvl */ 90 } fm_ioc_data_t; 91 92 #ifdef _KERNEL 93 typedef struct fm_ioc_data32 { 94 uint32_t fid_version; /* interface version */ 95 size32_t fid_insz; /* size of packed input nvlist */ 96 caddr32_t fid_inbuf; /* buf containing packed input nvl */ 97 size32_t fid_outsz; /* size of packed output nvlist */ 98 caddr32_t fid_outbuf; /* buf containing packed output nvl */ 99 } fm_ioc_data32_t; 100 #endif /* _KERNEL */ 101 102 /* 103 * Constants 104 */ 105 #define FM_PAGE_RETIRE_FMRI "fmri" 106 #define FM_PHYSCPU_INFO_CPUS "cpus" 107 #define FM_CPU_RETIRE_CHIP_ID "chip_id" 108 #define FM_PHYSCPU_INFO_NPROCNODES "procnodes_per_pkg" 109 #define FM_PHYSCPU_INFO_PROCNODE_ID "procnodeid" 110 #define FM_CPU_RETIRE_CORE_ID "core_id" 111 #define FM_CPU_RETIRE_STRAND_ID "strand_id" 112 #define FM_CPU_RETIRE_OLDSTATUS "oldstatus" 113 #define FM_GENTOPO_LEGACY "gentopolegacy" 114 #define FM_CACHE_INFO_NCPUS "ncpus" 115 116 /* 117 * Properties set by FM_PHYSCPU_INFO 118 */ 119 #define FM_PHYSCPU_INFO_VENDOR_ID "vendor_id" 120 #define FM_PHYSCPU_INFO_FAMILY "family" 121 #define FM_PHYSCPU_INFO_MODEL "model" 122 #define FM_PHYSCPU_INFO_STEPPING "stepping" 123 124 /* 125 * When Multi-Chip-Module(MCM) support is added 126 * chip_id should map to the processor package 127 * and not the die in the processor package. 128 * This is for FMA; kernel's perception of 129 * chip_id could differ for MCM. 130 */ 131 #define FM_PHYSCPU_INFO_CHIP_ID "chip_id" 132 133 #define FM_PHYSCPU_INFO_CORE_ID "core_id" 134 #define FM_PHYSCPU_INFO_STRAND_ID "strand_id" 135 #define FM_PHYSCPU_INFO_STRAND_APICID "strand_initial_apicid" 136 #define FM_PHYSCPU_INFO_SMBIOS_ID "smbios_id" 137 #define FM_PHYSCPU_INFO_CHIP_ROOTS "chip_roots" 138 #define FM_PHYSCPU_INFO_CHIP_REV "chip_rev" 139 #define FM_PHYSCPU_INFO_SOCKET_TYPE "socket_type" 140 #define FM_PHYSCPU_INFO_CPU_ID "cpuid" 141 #define FM_PHYSCPU_INFO_CHIP_IDENTSTR "chip_identstr" 142 143 /* 144 * Information exposed by the cache information structure. This is currently 145 * organized by the given caches available to a CPU. There is a given nvlist_t 146 * array for each cache level. The majority of these entries are meant to be 147 * generic across all platforms and derived from the underlying architecture's 148 * metadata (CPUID, CLIDR_EL1, etc.). 149 * 150 * The FM_CACHE_INFO_ID value is manufactured by the kernel. CPU architectures 151 * generally present cache information as specific to a logical CPU. This allows 152 * systems to determine what level caches are shared between different CPUs by 153 * comparing these entries across CPUs. Items prefixed with a given architecture 154 * are specific to it and will not show up on other platforms. These exist so 155 * topology modules can have more information than just the cache-id. While it's 156 * helpful, it doesn't tell us what level of the CPU (or whether it's internal 157 * or external) it exists at. This is going to be architecture and potentially 158 * platform specific given that ARMv8-A/ARMv9-A doesn't define a way to get this 159 * for example. 160 * 161 * It is expected that callers will always fill out the sets and ways 162 * appropriately. If a cache is fully-associative, we expects the number of sets 163 * to be populated and set to 1 that way consumers can attempt to have a uniform 164 * experience here. 165 */ 166 #define FM_CACHE_INFO_LEVEL "cache-level" /* uint32_t */ 167 #define FM_CACHE_INFO_TYPE "cache-type" /* uint32_t */ 168 typedef enum { 169 FM_CACHE_INFO_T_DATA = 1 << 0, 170 FM_CACHE_INFO_T_INSTR = 1 << 1, 171 FM_CACHE_INFO_T_UNIFIED = 1 << 2 172 } fm_cache_info_type_t; 173 #define FM_CACHE_INFO_NSETS "cache-sets" /* uint64_t */ 174 #define FM_CACHE_INFO_NWAYS "cache-ways" /* uint32_t */ 175 #define FM_CACHE_INFO_LINE_SIZE "line-size" /* uint32_t */ 176 #define FM_CACHE_INFO_TOTAL_SIZE "total-size" /* uint64_t */ 177 #define FM_CACHE_INFO_FULLY_ASSOC "fully-associative" /* boolean (key) */ 178 #define FM_CACHE_INFO_ID "cache-id" /* uint64_t */ 179 #define FM_CACHE_INFO_X86_APIC_SHIFT "x86-apic-shift" /* uint32_t */ 180 181 /* 182 * Information returned in the physical CPU PCI information structure. 183 * 184 * data_fabrics is an array with an entry for each physical CPU and the PCI bus 185 * number of the corresponding northbridge. This is currently only supported 186 * for AMD processors and the shape of this interface may change in the future 187 * once support for Intel processors is added. 188 */ 189 #define FM_PCI_DATA_DFS "data_fabrics" 190 #define FM_PCI_DATA_CHIP_ID "chip_id" 191 #define FM_PCI_DATA_NB_BUSNO "nb_busno" 192 193 #ifdef __cplusplus 194 } 195 #endif 196 197 #endif /* _SYS_DEVFM_H */ 198