xref: /illumos-gate/usr/src/uts/intel/sys/mc.h (revision 9b664393d4fdda96221e6ea9ea95790d3c15be70)
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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
22  * Use is subject to license terms.
23  */
24 /*
25  * Copyright 2019 Joyent, Inc.
26  */
27 
28 #ifndef _SYS_MC_H
29 #define	_SYS_MC_H
30 
31 /*
32  * Public interfaces exposed by the memory controller driver
33  */
34 
35 #include <sys/cpuvar.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #define	MC_UNUM_NAMLEN		192
42 #define	MC_UNUM_NDIMM		2
43 
44 typedef struct mc_unum {
45 	int unum_board;			/* system board */
46 	int unum_chip;			/* chip/socket */
47 	int unum_mc;			/* memory-controller or branch */
48 	int unum_chan;			/* DRAM channel */
49 	int unum_cs;			/* chip-select */
50 	int unum_rank;			/* rank */
51 	uint64_t unum_offset;		/* row, column, bank-select etc */
52 	int unum_dimms[MC_UNUM_NDIMM];
53 } mc_unum_t;
54 
55 /*
56  * Invalid marker used in some numeric properties
57  */
58 #define	MC_INVALNUM		((uint32_t)-1)
59 
60 /*
61  * /dev/mc/mc* ioctl cmds
62  */
63 #define	MC_IOC			(0x4d43 << 16)
64 #define	MC_IOC_SNAPSHOT_INFO	(MC_IOC | 1)
65 #define	MC_IOC_SNAPSHOT		(MC_IOC | 2)
66 #define	MC_IOC_ONLINESPARE_EN	(MC_IOC | 4)
67 #define	MC_IOC_DECODE_PA	(MC_IOC | 5)
68 #define	MC_IOC_DECODE_SNAPSHOT_INFO	(MC_IOC | 6)
69 #define	MC_IOC_DECODE_SNAPSHOT	(MC_IOC | 7)
70 
71 /*
72  * Prior to requesting a copy of the snapshot, consumers are advised to request
73  * information regarding the snapshot.  An mc_snapshot_info_t will be returned,
74  * containing the snapshot size as well as the snapshot generation number.  Note
75  * that, due to the potentially dynamic nature of the system, the snapshot may
76  * change at any time.  As such, the information in the mc_snapshot_info_t may
77  * be out of date by the time it is used.  The generation number is used to
78  * track snapshot changes.  That is, the generation number will be updated each
79  * time the source data for the snapshot is updated.  The consumer should not
80  * attach any meaning to the magnitude of a generation number change, and pay
81  * attention only to the fact that the number has changed.
82  */
83 typedef struct mc_snapshot_info {
84 	uint32_t mcs_size;	/* snapshot size */
85 	uint_t mcs_gen;		/* snapshot generation number */
86 } mc_snapshot_info_t;
87 
88 /*
89  * Data used to simulate encoding or decoding of a physical / DIMM address.
90  */
91 typedef struct mc_encode_ioc {
92 	uint64_t	mcei_pa;
93 	uint64_t	mcei_errdata;
94 	uint32_t	mcei_err;
95 	uint32_t	mcei_board;
96 	uint32_t	mcei_chip;
97 	uint32_t	mcei_mc;
98 	uint32_t	mcei_chan;
99 	uint32_t	mcei_dimm;
100 	uint64_t	mcei_rank_addr;
101 	uint32_t	mcei_rank;
102 	uint32_t	mcei_row;
103 	uint32_t	mcei_column;
104 	uint32_t	mcei_pad;
105 } mc_encode_ioc_t;
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif /* _SYS_MC_H */
112