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 5*b1c4bcc2Stsien * Common Development and Distribution License (the "License"). 6*b1c4bcc2Stsien * 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 /* 237aec1d6eScindi * Copyright 2006 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 * 837c478bd9Sstevel@tonic-gate * - expand: At the time of this writing, no platforms include bank or DIMM 847c478bd9Sstevel@tonic-gate * serial numbers in their ereports. As such, the serial number(s) must 857c478bd9Sstevel@tonic-gate * be added by the diagnosis engine. This entry point will read the 867c478bd9Sstevel@tonic-gate * serial number(s) for the named item, and will add it/them to the passed 877c478bd9Sstevel@tonic-gate * FMRI. Errors will be returned if the FMRI (unum) was unparseable, or if 887c478bd9Sstevel@tonic-gate * the serial number could not be retrieved. 897c478bd9Sstevel@tonic-gate * 907c478bd9Sstevel@tonic-gate * - present: Given a mem-schemed FMRI with a serial number, this entry 917c478bd9Sstevel@tonic-gate * point will attempt to determine whether the bank or module named in the 927c478bd9Sstevel@tonic-gate * FMRI is still present in the system at the same location. Programmer 937c478bd9Sstevel@tonic-gate * errors (invalid FMRIs) will be signalled to the caller. Warnings will 947c478bd9Sstevel@tonic-gate * be emitted for otherwise-valid FMRIs whose serial numbers could not be 957c478bd9Sstevel@tonic-gate * read, with the caller told that the FMRI is not present. 967c478bd9Sstevel@tonic-gate * 977c478bd9Sstevel@tonic-gate * - contains: Used to determine whether a given bank contains a given DIMM. 987c478bd9Sstevel@tonic-gate * No attempt is made to determine whether the module named by the FMRIs are 997c478bd9Sstevel@tonic-gate * actually present in the system. Programmer errors (invalidd FMRIs) will 1007c478bd9Sstevel@tonic-gate * be returned to the caller. Warnings will be emitted for otherwise-valid 1017c478bd9Sstevel@tonic-gate * FMRIs whose relationship could not be determined, with the caller told 1027c478bd9Sstevel@tonic-gate * that there is no relationship. 1037c478bd9Sstevel@tonic-gate */ 1047c478bd9Sstevel@tonic-gate 105*b1c4bcc2Stsien /* 18+nul for SPD, 6+nul for SEEPROM, 15+nul max for Serengeti, Starcat, LW8 */ 106*b1c4bcc2Stsien #define MEM_SERID_MAXLEN 20 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate typedef struct mem_dimm_map { 1097c478bd9Sstevel@tonic-gate struct mem_dimm_map *dm_next; /* The next DIMM map */ 1107c478bd9Sstevel@tonic-gate char *dm_label; /* The UNUM for this DIMM */ 1117c478bd9Sstevel@tonic-gate char *dm_device; /* Path to I2C device for DIMM */ 1127c478bd9Sstevel@tonic-gate char dm_serid[MEM_SERID_MAXLEN]; /* Cached serial number */ 1137c478bd9Sstevel@tonic-gate uint64_t dm_drgen; /* DR gen count for cached S/N */ 1147c478bd9Sstevel@tonic-gate } mem_dimm_map_t; 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate typedef struct mem { 1177c478bd9Sstevel@tonic-gate mem_dimm_map_t *mem_dm; /* List supported DIMMs */ 118822fb41dStsien uint64_t mem_memconfig; /* HV memory-configuration-id# */ 1197c478bd9Sstevel@tonic-gate } mem_t; 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate extern int mem_discover(void); 1227c478bd9Sstevel@tonic-gate extern int mem_get_serid(const char *, char *, size_t); 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate extern int mem_unum_burst(const char *, char ***, size_t *); 1257c478bd9Sstevel@tonic-gate extern int mem_unum_contains(const char *, const char *); 1267aec1d6eScindi extern int mem_unum_rewrite(nvlist_t *, nvlist_t **); 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate extern void mem_strarray_free(char **, size_t); 129d00f0155Sayznaga extern int mem_page_cmd(int, nvlist_t *); 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate extern mem_t mem; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate #endif 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate #endif /* _MEM_H */ 138