xref: /illumos-gate/usr/src/cmd/fm/schemes/mem/mem.h (revision fbd1c0dae6f4a2ccc2ce0527c7f19d3dd5ea90b8)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5b1c4bcc2Stsien  * Common Development and Distribution License (the "License").
6b1c4bcc2Stsien  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217aec1d6eScindi 
227c478bd9Sstevel@tonic-gate /*
23*fbd1c0daSsd77468  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef _MEM_H
287c478bd9Sstevel@tonic-gate #define	_MEM_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bd9Sstevel@tonic-gate 
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
33d00f0155Sayznaga #include <sys/nvpair.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef __cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate /*
407c478bd9Sstevel@tonic-gate  * FMRI plugin for the `mem' scheme.
417c478bd9Sstevel@tonic-gate  *
427c478bd9Sstevel@tonic-gate  * The mem scheme can be used to name individual memory modules, as well as
437c478bd9Sstevel@tonic-gate  * groups of memory modules, also known as banks.  The name `dimm' is used as a
447c478bd9Sstevel@tonic-gate  * synonym for individual memory modules, for no good reason.  Mem FMRIs can
457c478bd9Sstevel@tonic-gate  * be further refined with the addition of a member which identifies a
467c478bd9Sstevel@tonic-gate  * particular physical page within the bank or DIMM.  The named page is as
477c478bd9Sstevel@tonic-gate  * viewed by the VM system, and may thus span multiple memory modules.  It will,
487c478bd9Sstevel@tonic-gate  * however, be at least partially contained by the named bank or DIMM.
497c478bd9Sstevel@tonic-gate  *
507c478bd9Sstevel@tonic-gate  * Memory modules are identified by two things - their physical position, or
517c478bd9Sstevel@tonic-gate  * slot, in the machine, and their serial number.  DIMMs are identified by this
527c478bd9Sstevel@tonic-gate  * tuple on platforms which support the retrieval of serial numbers.  Platforms
537c478bd9Sstevel@tonic-gate  * which don't have this support rely on the slot number, with the corresponding
547c478bd9Sstevel@tonic-gate  * degradation in their ability to detect hardware changees.
557c478bd9Sstevel@tonic-gate  *
567c478bd9Sstevel@tonic-gate  * The physical location is embodied by the unum, which is highly specific to
577c478bd9Sstevel@tonic-gate  * each platform, and bears a passing resemblance to the name of the slot, as
587c478bd9Sstevel@tonic-gate  * printed on the actual hardware.  The unum is mapped to a DIMM-specific
597c478bd9Sstevel@tonic-gate  * device, which is then read to determine the serial number.  See mem_disc.c
607c478bd9Sstevel@tonic-gate  * for details of the process by which unums are mapped to devices, and
617c478bd9Sstevel@tonic-gate  * mem_read.c for the code which actually retrieves the serial number from the
627c478bd9Sstevel@tonic-gate  * device.
637c478bd9Sstevel@tonic-gate  *
647c478bd9Sstevel@tonic-gate  * Banks are also identified by unums, which must be broken apart into the
657c478bd9Sstevel@tonic-gate  * unums which identify each constituent memory module.  Serial numbers are
667c478bd9Sstevel@tonic-gate  * retrieved for banks - one per member module - in the same way as for
677c478bd9Sstevel@tonic-gate  * individual modules.  See mem_unum.c for the code which bursts bank unums.
687c478bd9Sstevel@tonic-gate  *
697c478bd9Sstevel@tonic-gate  * Serial number retrieval, on platforms which support it, is very expensive
707c478bd9Sstevel@tonic-gate  * (on the order of several tenths of a second, which adds up in a hurry on
717c478bd9Sstevel@tonic-gate  * larger machines).  So, while we pre-generate the list of DIMM device paths,
727c478bd9Sstevel@tonic-gate  * we only read their serial numbers when requested by plugin consumers.  To
737c478bd9Sstevel@tonic-gate  * further reduce the perceived cost, we don't re-read until/unless we detect
747c478bd9Sstevel@tonic-gate  * that a DR operation has taken place.
757c478bd9Sstevel@tonic-gate  *
767c478bd9Sstevel@tonic-gate  * Using the facilities described above, the plugin implements the following
777c478bd9Sstevel@tonic-gate  * entry points: (see mem.c)
787c478bd9Sstevel@tonic-gate  *
797c478bd9Sstevel@tonic-gate  *   - nvl2str: The printed representation of the named bank or DIMM is
807c478bd9Sstevel@tonic-gate  *     generated.  No attempt is made to determine whether or not the named
817c478bd9Sstevel@tonic-gate  *     item is still present in the system.
827c478bd9Sstevel@tonic-gate  *
83*fbd1c0daSsd77468  *   - expand: For platforms which do not include bank or DIMM
84*fbd1c0daSsd77468  *     serial numbers in their ereports, this entry point will read the
857c478bd9Sstevel@tonic-gate  *     serial number(s) for the named item, and will add it/them to the passed
867c478bd9Sstevel@tonic-gate  *     FMRI.  Errors will be returned if the FMRI (unum) was unparseable, or if
877c478bd9Sstevel@tonic-gate  *     the serial number could not be retrieved.
887c478bd9Sstevel@tonic-gate  *
897c478bd9Sstevel@tonic-gate  *   - present: Given a mem-schemed FMRI with a serial number, this entry
907c478bd9Sstevel@tonic-gate  *     point will attempt to determine whether the bank or module named in the
917c478bd9Sstevel@tonic-gate  *     FMRI is still present in the system at the same location.  Programmer
927c478bd9Sstevel@tonic-gate  *     errors (invalid FMRIs) will be signalled to the caller.  Warnings will
937c478bd9Sstevel@tonic-gate  *     be emitted for otherwise-valid FMRIs whose serial numbers could not be
947c478bd9Sstevel@tonic-gate  *     read, with the caller told that the FMRI is not present.
957c478bd9Sstevel@tonic-gate  *
967c478bd9Sstevel@tonic-gate  *   - contains: Used to determine whether a given bank contains a given DIMM.
977c478bd9Sstevel@tonic-gate  *     No attempt is made to determine whether the module named by the FMRIs are
987c478bd9Sstevel@tonic-gate  *     actually present in the system.  Programmer errors (invalidd FMRIs) will
997c478bd9Sstevel@tonic-gate  *     be returned to the caller.  Warnings will be emitted for otherwise-valid
1007c478bd9Sstevel@tonic-gate  *     FMRIs whose relationship could not be determined, with the caller told
1017c478bd9Sstevel@tonic-gate  *     that there is no relationship.
1027c478bd9Sstevel@tonic-gate  */
1037c478bd9Sstevel@tonic-gate 
1040cc8ae86Sav145390 /*
1050cc8ae86Sav145390  * 18+nul for SPD, 6+nul for SEEPROM, 15+nul max for Serengeti, Starcat, LW8.
1060cc8ae86Sav145390  * 18 for Sun Partnumber, 18 partner partnumber, 12 serialnumber for OPL.
1070cc8ae86Sav145390  */
1080cc8ae86Sav145390 #define	MEM_SERID_MAXLEN	64
1097c478bd9Sstevel@tonic-gate 
110*fbd1c0daSsd77468 typedef struct mem_seg_map {
111*fbd1c0daSsd77468 	struct mem_seg_map *sm_next;	/* the next segment map */
112*fbd1c0daSsd77468 	uint64_t	sm_base;	/* base address for this segment */
113*fbd1c0daSsd77468 	uint64_t	sm_size;	/* size for this segment */
114*fbd1c0daSsd77468 	uint64_t	sm_mask;	/* mask denoting dimm selection bits */
115*fbd1c0daSsd77468 	uint64_t	sm_match;	/* value selecting this set of DIMMs */
116*fbd1c0daSsd77468 	uint16_t	sm_shift;	/* dimms-per-reference shift */
117*fbd1c0daSsd77468 } mem_seg_map_t;
118*fbd1c0daSsd77468 
1197c478bd9Sstevel@tonic-gate typedef struct mem_dimm_map {
1207c478bd9Sstevel@tonic-gate 	struct mem_dimm_map *dm_next;	/* The next DIMM map */
1217c478bd9Sstevel@tonic-gate 	char *dm_label;			/* The UNUM for this DIMM */
1227c478bd9Sstevel@tonic-gate 	char *dm_device;		/* Path to I2C device for DIMM */
1237c478bd9Sstevel@tonic-gate 	char dm_serid[MEM_SERID_MAXLEN]; /* Cached serial number */
12414ea4bb7Ssd77468 	char *dm_part;			/* DIMM part number */
1257c478bd9Sstevel@tonic-gate 	uint64_t dm_drgen;		/* DR gen count for cached S/N */
126*fbd1c0daSsd77468 	mem_seg_map_t *dm_seg;		/* segment for this DIMM */
1277c478bd9Sstevel@tonic-gate } mem_dimm_map_t;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate typedef struct mem {
1307c478bd9Sstevel@tonic-gate 	mem_dimm_map_t *mem_dm;		/* List supported DIMMs */
131822fb41dStsien 	uint64_t mem_memconfig;		/* HV memory-configuration-id# */
132*fbd1c0daSsd77468 	mem_seg_map_t *mem_seg;		/* list of defined segments */
1337c478bd9Sstevel@tonic-gate } mem_t;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate extern int mem_discover(void);
1367c478bd9Sstevel@tonic-gate extern int mem_get_serid(const char *, char *, size_t);
137*fbd1c0daSsd77468 extern int mem_get_serids_by_unum(const char *, char ***, size_t *);
138*fbd1c0daSsd77468 extern void mem_expand_opt(nvlist_t *, char *, char **);
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate extern int mem_unum_burst(const char *, char ***, size_t *);
1417c478bd9Sstevel@tonic-gate extern int mem_unum_contains(const char *, const char *);
1427aec1d6eScindi extern int mem_unum_rewrite(nvlist_t *, nvlist_t **);
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate extern void mem_strarray_free(char **, size_t);
145d00f0155Sayznaga extern int mem_page_cmd(int, nvlist_t *);
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate extern mem_t mem;
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1507c478bd9Sstevel@tonic-gate }
1517c478bd9Sstevel@tonic-gate #endif
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate #endif /* _MEM_H */
154