xref: /illumos-gate/usr/src/lib/fm/topo/modules/i86pc/chip/chip.h (revision d8849d7dee03b84a3fa281ec65eb9e3d86d3756b)
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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright 2019, Joyent, Inc.
24  */
25 
26 #ifndef _CHIP_H
27 #define	_CHIP_H
28 
29 #include <kstat.h>
30 #include <libnvpair.h>
31 #include <fm/libtopo.h>
32 #include <fm/topo_mod.h>
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define	CHIP_VERSION		TOPO_VERSION
39 
40 /* Below should match the definitions in x86pi_impl.h */
41 #define	X86PI_FULL		1
42 #define	X86PI_NONE		2
43 
44 /*
45  * FM_AWARE_SMBIOS means SMBIOS meets FMA needs
46  * X86PI_FULL is defined as 1 in x86pi.so
47  * And passed from x86pi.so to chip.so as module
48  * private data
49  */
50 #define	FM_AWARE_SMBIOS(mod)	\
51 	(topo_mod_getspecific(mod) != NULL && \
52 	    (*(int *)topo_mod_getspecific(mod) == X86PI_FULL))
53 #define	IGNORE_ID	0xFFFF
54 
55 /*
56  * These definitions are for the Tree Nodes
57  * in the FM Topology
58  */
59 #define	CHIP_NODE_NAME		"chip"
60 #define	CORE_NODE_NAME		"core"
61 #define	STRAND_NODE_NAME	"strand"
62 #define	MCT_NODE_NAME		"memory-controller"
63 #define	CHAN_NODE_NAME		"dram-channel"
64 #define	CS_NODE_NAME		"chip-select"
65 #define	DIMM_NODE_NAME		"dimm"
66 #define	RANK_NODE_NAME		"rank"
67 
68 #define	PGNAME(prefix)	(prefix##_NODE_NAME "-properties")
69 
70 /*
71  * chip-properties
72  */
73 #define	CHIP_BRAND		"brand"
74 #define	CHIP_FAMILY		"family"
75 #define	CHIP_MODEL		"model"
76 #define	CHIP_NCORE		"ncore_per_chip"
77 #define	CHIP_STEPPING		"stepping"
78 #define	CHIP_VENDOR_ID		"vendor_id"
79 
80 /*
81  * memory-controller-properties
82  * check usr/src/uts/i86pc/os/cpuid.c to understand more
83  * on procnodeid values for AMD & Intel
84  */
85 #define	MCT_PROCNODE_ID		"procnodeid"
86 
87 /*
88  * core-properties
89  */
90 #define	CORE_CHIP_ID		"chip_id"
91 #define	CORE_PROCNODE_ID	"procnodeid"
92 
93 /*
94  * strand-properties
95  */
96 #define	STRAND_CHIP_ID		"chip_id"
97 #define	STRAND_PROCNODE_ID	"procnodeid"
98 #define	STRAND_CORE_ID		"core_id"
99 #define	STRAND_PKG_CORE_ID	"pkg_core_id"
100 #define	STRAND_CPU_ID		"cpuid"
101 
102 /*
103  * label property methods
104  */
105 #define	SIMPLE_DIMM_LBL		"simple_dimm_label"
106 #define	SIMPLE_DIMM_LBL_MP	"simple_dimm_label_mp"
107 #define	SEQ_DIMM_LBL		"seq_dimm_label"
108 #define	G4_DIMM_LBL		"g4_dimm_label"
109 #define	G12F_DIMM_LBL		"g12f_dimm_label"
110 #define	SIMPLE_CHIP_LBL		"simple_chip_label"
111 #define	G4_CHIP_LBL		"g4_chip_label"
112 #define	A4FPLUS_CHIP_LBL	"a4fplus_chip_label"
113 #define	SIMPLE_CS_LBL_MP	"simple_cs_label_mp"
114 #define	FSB2_CHIP_LBL		"fsb2_chip_label"
115 
116 /*
117  * DIMM serial number property methods
118  */
119 #define	GET_DIMM_SERIAL		"get_dimm_serial"
120 
121 extern int simple_dimm_label(topo_mod_t *, tnode_t *, topo_version_t,
122     nvlist_t *, nvlist_t **);
123 extern int simple_dimm_label_mp(topo_mod_t *, tnode_t *, topo_version_t,
124     nvlist_t *, nvlist_t **);
125 extern int seq_dimm_label(topo_mod_t *, tnode_t *, topo_version_t,
126     nvlist_t *, nvlist_t **);
127 extern int g4_dimm_label(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
128     nvlist_t **);
129 
130 extern int g12f_dimm_label(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
131     nvlist_t **);
132 
133 extern int simple_chip_label(topo_mod_t *, tnode_t *, topo_version_t,
134     nvlist_t *, nvlist_t **);
135 extern int g4_chip_label(topo_mod_t *, tnode_t *, topo_version_t,
136     nvlist_t *, nvlist_t **);
137 extern int a4fplus_chip_label(topo_mod_t *, tnode_t *, topo_version_t,
138     nvlist_t *, nvlist_t **);
139 extern int simple_cs_label_mp(topo_mod_t *, tnode_t *, topo_version_t,
140     nvlist_t *, nvlist_t **);
141 extern int get_dimm_serial(topo_mod_t *, tnode_t *, topo_version_t, nvlist_t *,
142     nvlist_t **);
143 extern int fsb2_chip_label(topo_mod_t *, tnode_t *, topo_version_t,
144     nvlist_t *, nvlist_t **);
145 
146 /*
147  * Support functions of chip_subr.c
148  */
149 extern void whinge(topo_mod_t *, int *, const char *, ...);
150 extern int nvprop_add(topo_mod_t *, nvpair_t *, const char *, tnode_t *);
151 extern int add_nvlist_strprop(topo_mod_t *, tnode_t *, nvlist_t *,
152     const char *, const char *, const char **);
153 extern int add_nvlist_longprop(topo_mod_t *, tnode_t *, nvlist_t *,
154     const char *, const char *, int32_t *);
155 extern int add_nvlist_longprops(topo_mod_t *, tnode_t *, nvlist_t *,
156     const char *, int32_t *, ...);
157 extern int mkrsrc(topo_mod_t *, tnode_t *, const char *, int,
158     nvlist_t *, nvlist_t **);
159 extern nvlist_t *cpu_fmri_create(topo_mod_t *, uint32_t, char *, uint8_t);
160 extern boolean_t is_xpv();
161 extern const char *get_chip_brand(topo_mod_t *, kstat_ctl_t *, int32_t);
162 
163 /*
164  * topo methods
165  */
166 extern int mem_asru_compute(topo_mod_t *, tnode_t *, topo_version_t,
167     nvlist_t *, nvlist_t **);
168 extern int rank_fmri_present(topo_mod_t *, tnode_t *, topo_version_t,
169     nvlist_t *, nvlist_t **);
170 extern int rank_fmri_replaced(topo_mod_t *, tnode_t *, topo_version_t,
171     nvlist_t *, nvlist_t **);
172 extern int retire_strands(topo_mod_t *, tnode_t *, topo_version_t,
173     nvlist_t *, nvlist_t **);
174 extern int unretire_strands(topo_mod_t *, tnode_t *, topo_version_t,
175     nvlist_t *, nvlist_t **);
176 extern int service_state_strands(topo_mod_t *, tnode_t *, topo_version_t,
177     nvlist_t *, nvlist_t **);
178 extern int unusable_strands(topo_mod_t *, tnode_t *, topo_version_t,
179     nvlist_t *, nvlist_t **);
180 extern int ntv_page_retire(topo_mod_t *, tnode_t *, topo_version_t,
181     nvlist_t *, nvlist_t **);
182 extern int ntv_page_service_state(topo_mod_t *, tnode_t *, topo_version_t,
183     nvlist_t *, nvlist_t **);
184 extern int ntv_page_unretire(topo_mod_t *, tnode_t *, topo_version_t,
185     nvlist_t *, nvlist_t **);
186 extern int ntv_page_unusable(topo_mod_t *, tnode_t *, topo_version_t,
187     nvlist_t *, nvlist_t **);
188 extern int chip_fmri_replaced(topo_mod_t *, tnode_t *, topo_version_t,
189     nvlist_t *, nvlist_t **);
190 
191 extern int mem_asru_create(topo_mod_t *, nvlist_t *, nvlist_t **);
192 
193 /*
194  * Prototypes for chip_amd.c
195  */
196 extern void amd_mc_create(topo_mod_t *, uint16_t, tnode_t *, const char *,
197     nvlist_t *, int32_t, int32_t, int, int, int *);
198 
199 /*
200  * Prototypes for chip_intel.c
201  */
202 extern int mc_offchip_open(void);
203 extern int mc_offchip_create(topo_mod_t *, tnode_t *, const char *, nvlist_t *);
204 extern void onchip_mc_create(topo_mod_t *, uint16_t, tnode_t *,
205     const char *, nvlist_t *);
206 
207 extern char *get_fmtstr(topo_mod_t *, nvlist_t *);
208 extern int store_prop_val(topo_mod_t *, char *, char *, nvlist_t **out);
209 
210 /*
211  * Prototypes for chip_smbios.c
212  */
213 
214 extern int init_chip_smbios(topo_mod_t *);
215 extern int chip_status_smbios_get(topo_mod_t *, id_t);
216 extern int chip_fru_smbios_get(topo_mod_t *, id_t);
217 extern const char *chip_label_smbios_get(topo_mod_t *, tnode_t *, id_t, char *);
218 extern const char *chip_serial_smbios_get(topo_mod_t *, id_t);
219 extern const char *chip_part_smbios_get(topo_mod_t *, id_t);
220 extern const char *chip_rev_smbios_get(topo_mod_t *, id_t);
221 extern id_t memnode_to_smbiosid(topo_mod_t *, uint16_t, const char *,
222     uint64_t, void *);
223 
224 /*
225  * Prototypes for chip_temp.c
226  */
227 extern int chip_create_chip_temp_sensor(topo_mod_t *, tnode_t *);
228 extern int chip_create_core_temp_sensor(topo_mod_t *, tnode_t *);
229 
230 #ifdef __cplusplus
231 }
232 #endif
233 
234 #endif /* _CHIP_H */
235