xref: /titanic_41/usr/src/cmd/fm/schemes/mem/mem.h (revision c5805b0b8f18ce47991b05b08dc6bedc8a549f49)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _MEM_H
28 #define	_MEM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/mdesc.h>
34 #include <sys/nvpair.h>
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * FMRI plugin for the `mem' scheme.
42  *
43  * The mem scheme can be used to name individual memory modules, as well as
44  * groups of memory modules, also known as banks.  The name `dimm' is used as a
45  * synonym for individual memory modules, for no good reason.  Mem FMRIs can
46  * be further refined with the addition of a member which identifies a
47  * particular physical page within the bank or DIMM.  The named page is as
48  * viewed by the VM system, and may thus span multiple memory modules.  It will,
49  * however, be at least partially contained by the named bank or DIMM.
50  *
51  * Memory modules are identified by two things - their physical position, or
52  * slot, in the machine, and their serial number.  DIMMs are identified by this
53  * tuple on platforms which support the retrieval of serial numbers.  Platforms
54  * which don't have this support rely on the slot number, with the corresponding
55  * degradation in their ability to detect hardware changees.
56  *
57  * The physical location is embodied by the unum, which is highly specific to
58  * each platform, and bears a passing resemblance to the name of the slot, as
59  * printed on the actual hardware.  The unum is mapped to a DIMM-specific
60  * device, which is then read to determine the serial number.  See mem_disc.c
61  * for details of the process by which unums are mapped to devices, and
62  * mem_read.c for the code which actually retrieves the serial number from the
63  * device.
64  *
65  * Banks are also identified by unums, which must be broken apart into the
66  * unums which identify each constituent memory module.  Serial numbers are
67  * retrieved for banks - one per member module - in the same way as for
68  * individual modules.  See mem_unum.c for the code which bursts bank unums.
69  *
70  * Serial number retrieval, on platforms which support it, is very expensive
71  * (on the order of several tenths of a second, which adds up in a hurry on
72  * larger machines).  So, while we pre-generate the list of DIMM device paths,
73  * we only read their serial numbers when requested by plugin consumers.  To
74  * further reduce the perceived cost, we don't re-read until/unless we detect
75  * that a DR operation has taken place.
76  *
77  * Using the facilities described above, the plugin implements the following
78  * entry points: (see mem.c)
79  *
80  *   - nvl2str: The printed representation of the named bank or DIMM is
81  *     generated.  No attempt is made to determine whether or not the named
82  *     item is still present in the system.
83  *
84  *   - expand: At the time of this writing, no platforms include bank or DIMM
85  *     serial numbers in their ereports.  As such, the serial number(s) must
86  *     be added by the diagnosis engine.  This entry point will read the
87  *     serial number(s) for the named item, and will add it/them to the passed
88  *     FMRI.  Errors will be returned if the FMRI (unum) was unparseable, or if
89  *     the serial number could not be retrieved.
90  *
91  *   - present: Given a mem-schemed FMRI with a serial number, this entry
92  *     point will attempt to determine whether the bank or module named in the
93  *     FMRI is still present in the system at the same location.  Programmer
94  *     errors (invalid FMRIs) will be signalled to the caller.  Warnings will
95  *     be emitted for otherwise-valid FMRIs whose serial numbers could not be
96  *     read, with the caller told that the FMRI is not present.
97  *
98  *   - contains: Used to determine whether a given bank contains a given DIMM.
99  *     No attempt is made to determine whether the module named by the FMRIs are
100  *     actually present in the system.  Programmer errors (invalidd FMRIs) will
101  *     be returned to the caller.  Warnings will be emitted for otherwise-valid
102  *     FMRIs whose relationship could not be determined, with the caller told
103  *     that there is no relationship.
104  */
105 
106 /* 8+nul for SPD, 6+nul for SEEPROM, 15+nul max for Serengeti, Starcat, LW8 */
107 #define	MEM_SERID_MAXLEN	16
108 #define	MDESC_PATH		"%s/devices/pseudo/mdesc@0:mdesc"
109 #define	MDESC_MAXPATHLEN	128
110 
111 typedef struct mem_dimm_map {
112 	struct mem_dimm_map *dm_next;	/* The next DIMM map */
113 	char *dm_label;			/* The UNUM for this DIMM */
114 	char *dm_device;		/* Path to I2C device for DIMM */
115 	char dm_serid[MEM_SERID_MAXLEN]; /* Cached serial number */
116 	uint64_t dm_drgen;		/* DR gen count for cached S/N */
117 } mem_dimm_map_t;
118 
119 typedef struct mem {
120 	mem_dimm_map_t *mem_dm;		/* List supported DIMMs */
121 	uint64_t mem_memconfig;		/* HV memory-configuration-id# */
122 	md_t *mem_mdp;			/* pointer to mdesc buffer */
123 	size_t mem_mdbufsz;		/* size of mdesc buffer */
124 } mem_t;
125 
126 extern md_t *mdesc_devinit(size_t *);
127 extern int mem_discover(void);
128 extern void mem_destroy(void);
129 
130 extern int mem_get_serid(const char *, char *, size_t);
131 
132 extern int mem_unum_burst(const char *, char ***, size_t *);
133 extern int mem_unum_contains(const char *, const char *);
134 
135 extern void mem_strarray_free(char **, size_t);
136 extern int mem_page_cmd(int, nvlist_t *);
137 
138 extern mem_t mem;
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* _MEM_H */
145